tags:

views:

1272

answers:

3

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
A: 

kindly see the java docs

Abid
But warpping it using Collections.synchronizedMap() makes it so.
Michael Borgwardt
Regardless, why this sarcastic tone with "my dear"? Smartass?
BalusC
Instead of editing you can also just delete the useless answer :)
BalusC
+3  A: 

ConcurrentHashMap is thread safe without synchronizing the whole map. Reads can happen very fast while write is done with a lock.

fastcodejava