On Sun, 2011-01-09 at 19:06 +0000, sebb wrote: > 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 >
I do not have a strong opinion on that. If a particular class does not need to be thread-safe I see nothing wrong with using HashMap, though. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
