A brief analysis of ConcurrentHashMap

1. Thread safety of ConcurrentHashMap The thread safety of ConcurrentHashMap means that the data structure of the Map will not be destroyed. For example, when performing a put operation on keys with the same hash value but not equal, it can be guaranteed that both keys are placed in the linked list (red-black binary tree) […]

ConcurrentHashMap vs HashMap time-consuming difference in single-threaded/multi-threaded get operations

The test module of the document is expanded in the form of try -> modify -> try again -> modify again… I hope to get a result from multiple tests, but think about it carefully: the final result of the experiment is only It will be a probability result, and multiple attempts will only increase […]

The underlying implementation of HashMap, LinkedHashMap, ConcurrentHashMap, ArrayList, and LinkedList.

The underlying implementation of HashMap, LinkedHashMap, ConcurrentHashMap, ArrayList, and LinkedList. HashMap related questions 1. Have you ever used HashMap? What is HashMap? Why do you use it? Used, HashMap is an asynchronous implementation of the Map interface based on hash tables. It allows null keys and null values, and HashMap relies on the design of […]

ConcurrentHashMap source code solution 2

ConcurrentHashMap source code solution 2 Red-black tree implementation explanation The red-black tree is a special balanced binary tree. It uses red and black colors to limit the height difference between the left and right sub-nodes of each node to no more than 2 times. This requires that when adding or deleting elements, adjustments must be […]

ConcurrentHashMap1.7 source code analysis

I have analyzed the structure of HashMap version 1.7, but HashMap is not thread-safe, multi-thread triggering expansion will also cause an infinite loop problem, then ConcurrentHashMap solves this problem, this is a thread-safe Map, then the corresponding internal implementation How is it? After a simple analysis, the same position as HashMap will not be repeated. […]

In-depth analysis of Java Map: master HashMap, TreeMap, LinkedHashMap and ConcurrentHashMap

Map interface In Java, the Map interface is a general collection of key-value pairs, which allows us to use a pair of key-values to store and access data. The key-value pair can be stored in the Map through the put(key, value) method, and then the corresponding value can be obtained through the get(key) method. Commonly […]

JDK 7 ConcurrentHashMap

Directory overview constructor analysis put process get process size calculation process Overview ConcurrentHashMap in JDK1.7 indirectly implements Map, and calls each element a segmented lock segment. Each segment is an array of HashEntry, called a table, and each element of a table is a One-way queue of HashEntry. “HashTable locks the entire container, ConcurrentHashMap locks […]