ConcurrentHashMap vs synchronizedMap() vs Hashtable

ConcurrentHashMapsyncronizedMap()Hashtable
Thread safety without locking the complete mapThread safety by locking the complete mapThread safety by locking the complete map
At a time multiple Threads are allowed to operate on map in safe mannerAt a time one single Thread is allowed to operate in safe mannerAt a time one single Thread is allowed to operate in safe manner
Write operation requires segment/bucket level locksEvery read and write operations requires total map lockEvery read and write operations requires total map lock
While iterating if modified we will not get ConcurrentModificationExceptionWhile iterating if modified we will get ConcurrentModificationExceptionWhile iterating if modified we will get ConcurrentModificationException
Iterator is fail fastIterator is fail safeIterator is fail safe
Null not allowed for both keys are valuesNull allowed for both keys and valuesNull not allowed for both keys are values
Introduced in v1.5Introduced in v1.2Introduced in v1.0 v(Legacy Class)

Leave a Comment