internal implementation of ConcurrentHashMap in java
The total ConcurrentHashMap object will be divided into multiple parts and for every part internally a Lock will be maintained.
It is based on Bucket level Locking.
ConcurrentHashMap is working on Concurrency Level.
At a time any number of threads can read the data of ConcurrentHashMap, But at a time only 16 threads can write and update data to ConcurrentHashMap object.
By default concurrency level of ConcurrentHashMap is 16, But we can increase this concurrency level.
While iterating ConcurrentHashMap object if any thread updated some value in existing ConcurrentHashMap then it is not predictable to Iterator will iterate that updated value.
What is concurrency level
Object of ConcurrentHashMap will be divided into some number of parts that number is called concurrency level.
What is Concurrency
The object of ConcurrentHashMap will be divided into different segment and these segment will be Locked individually that is called Concurrency Level.
Compare locking between Hashtable and ConcurrentHashMap