What is the difference between using the wrapped class, SynchronizedMap, on a HashMap and ConcurrentHashMap? Is it just being able to modify the hashmap while iterating it (ConcurrentHashMap)?
+11
A:
The short answer:
Both maps are thread-safe implementations of the Map interface. ConcurrentHashMap is implemented for higher throughput in cases where high concurrency is expected.
Brian Goetz's article on the idea behind ConcurrentHashMap is a very good read. Highly recommended.
trshiv
2009-08-18 04:47:45
But warpping it using Collections.synchronizedMap() makes it so.
Michael Borgwardt
2010-05-28 13:34:53
Regardless, why this sarcastic tone with "my dear"? Smartass?
BalusC
2010-05-28 13:35:56
Instead of editing you can also just delete the useless answer :)
BalusC
2010-05-28 13:37:58
+3
A:
ConcurrentHashMap
is thread safe without synchronizing the whole map. Reads can happen very fast while write is done with a lock.
fastcodejava
2010-05-28 13:35:49