AbstractCookieSpec uses an unsynchronised  HashMap, so is not thread-safe.

AIUI, ConcurrentHashMap has much better performance than a
synchronised HashMap - but of course we are not using synch here.

A quick test using the code at [1] (1 thread, 1 VM) appears to show
that the performance of CHM and HM is fairly similar:

Map type:           HashMap
Runtime:            3000
Number of threads:  1
Write probability:  0.6
Remove probability: 0.02
Ops per second:     1260837.0

Map type:           ConcurrentHashMap
Runtime:            3000
Number of threads:  1
Write probability:  0.6
Remove probability: 0.02
Ops per second:     1313171.0

So I wonder if we should consider replacing HashMap with
ConcurrentHashMap in Cookies and elsewhere in HttpClient?

[1] 
http://unserializableone.blogspot.com/2007/04/performance-comparision-between.html

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to