posted 14 years ago
The ConcurrentHashMap is broken up into small pieces called Segments that cover a specific range of Hashes. The Segments basically have final links to the next Node, so they can't change. Which means that a read can safely traverse from one Node to the next without worrying about interuption. When a modification makes a change to a Node it must remove the Node and insert a new one, which means it does not affect a Node that a retrieval is already using. It also always inserts the Node at the beginning of the link-list, meaning you are modifying the iteration of a get by inserting new elements as well.
Volatile variables help control where the iterations in the get occur.