Although HashTable and ConcurrentHashMap both implement map, their implementation methods are quite different. Why do we compare them? Because both implement Map and are synchronous sets, it is not meaningful to compare the implementation details. We only compare design methods and efficiency:
ConcurrentHashMap and HashTable use synchronized code blocks, while ConcurrentHashMap and HashTable use synchronized code blocks, and ConcurrentHashMap use synchronized code blocks. If the current hash position is empty, use cas. If it is not empty, use synchronized code blocks. The object to be synchronized is the node of the current array position, the first node in the list, or the root node in the red-black tree.
ConcurrentHashMap Supports concurrent operation of multiple threads. The same hash value is synchronized. In high concurrency, ConcurrentHashMap has higher performance than HashTable.
ConcurrentHashMap (array + list + red-black tree); TashTable (array + list + red-black tree)
Watch video: www.ixigua.com/68738135572…