ConcurrentHashMap in Java

The underlying data structure for ConcurrentHashMap is HashTable. 

ConcurrentHashMap allows concurrent read and thread-safe update operations. 

To perform read operation thread won’t require any lock but to perform update operation thread require a lock, but it is the lock of only a particular part of Map(Bucket level lock). Instead of whole map concurrent update achieved by internally dividing the map into a smaller portion which is defined by concurrency level. 

The default concurrency level is 16 i.e  ConcurrentHashMap allows simultaneously read and 16 write(update) operations. The value null is not allowed for both keys and values. While one thread is iterating the other thread can perform update operation and ConcurrentHashMap never throws  ConcurrentModificationException.

Default initial capacity equals 16

Default fill ratio equals 0.75

Post a Comment

Previous Post Next Post