"Concurrenthashmap is a thread-safe hash table", but the key and value are not allowed to be empty;
Hashtable and Concurrenthashmap are thread-safe, but Hashtable is a synchronization container, Concurrenthashmap is a concurrent container, using the lock separation strategy, in the concurrency environment, should make more
With Concurrenthashmap, it has very good concurrency and can be read and written by multiple threads at the same time. Hashtable can only read and write to one thread at a time.
Concurrenthashmap can be simply understood as multiple hashmap combinations, and the lock is not on Concurrenthashmap, but on some hashmap. (segment mechanism)
As can be seen from the Concurrenthashmap code, it introduces a concept of "segmented lock", which can be understood as splitting a large map into N small hashtable (segment), according to the Key.hashcode () To decide which Hashtable to put the key in.
In Concurrenthashmap, it is the time to divide the map into n segment,put and get, which is now calculated based on Key.hashcode () to which segment:
Learn from: http://blog.csdn.net/xuefeng0707/article/details/40834595
Java Concurrenthashmap Initial knowledge