ConcurrentHashMap
A thread-safe Map whose updates such as merge and compute run atomically per key.
In more detail
Many threads can read and update it without external locking, and its iterators never throw ConcurrentModificationException. It rejects null keys and values. It implements the ConcurrentMap interface.
Example
map.merge(word, 1, Integer::sum);Related terms
- Java Map — The collection interface that associates each unique key with one value, replacing the old value when a key is stored again.
- race condition — A bug whose outcome depends on the timing of two things happening at once.
Taught in
- Concurrent Collections And Parallel Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep