java.util.concurrent · java.base · since Java 1.5
ConcurrentHashMap
public class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
implements ConcurrentMap<K, V>, SerializableThe concurrent Map: lock-free reads, per-bin write locking, and atomic compound operations (computeIfAbsent, merge) that replace client-side locking entirely.
Key methods
V computeIfAbsent(K, Function<K,V>) | Atomic get-or-create (the mapping function runs under the bin lock — keep it short, no map reentry). |
V merge(K, V, BiFunction<V,V,V>) | Atomic insert-or-combine. |
V putIfAbsent(K, V) / boolean replace(K, V old, V new) | Atomic conditional writes. |
void forEach(long parallelismThreshold, BiConsumer) | Bulk parallel operations. |
static <K> KeySetView<K,Boolean> newKeySet() | A concurrent Set. |