What is the difference between using the wrapper class, SynchronizedMap
, on a HashMap
and ConcurrentHashMap
?
Is it just bein
SynchronizedMap
and ConcurrentHashMap
are both thread safe class and can be used in multithreaded application, the main difference between them is regarding how they achieve thread safety.
SynchronizedMap
acquires lock on the entire Map instance , while ConcurrentHashMap
divides the Map instance into multiple segments and locking is done on those.