Concurrenthashmap is the thread-safe version of HashMap, and it is worth mentioning that Concurrenthashmap does not use a lock to protect the entire hash area, but instead uses 16 locks, distinguishes the hash into 16 buckets, and each lock controls a bucket, That is, lock segments, which can be more granular lock objects, so the maximum provides 16 concurrent read and write, to improve throughput.
But this technology also brings bad places, such as some methods need to scan the hash area, such as the size () method or the Containsvalue () method, so that the child will use multiple locks instead of a lock to achieve, and when the need for more locks, there is a need for some technology, Lock in order to avoid deadlocks.
Original: http://blog.csdn.net/hongchangfirst/article/details/39667989
Author: Hongchangfirst
Hongchangfirst's homepage: http://blog.csdn.net/hongchangfirst
Java Concurrenthashmap Analysis