ProLesson 9.9Advanced3 min readUpdated 30 October 2026
Concurrent collections
Thread-safe collections built for heavy concurrency, including ConcurrentHashMap and its atomic methods, CopyOnWriteArrayList and BlockingQueue.
The normal collections (ArrayList, HashMap) aren't thread-safe. Wrapping them in synchronized works, but makes every thread wait for one big lock. The java.util.concurrent package has collections designed for many threads.
01Three ways to share a map
| Option | How it's thread-safe | Throughput under load |
|---|---|---|
Hashtable (legacy) | Every method synchronised on one lock | Poor |
Collections.synchronizedMap(map) | A wrapper with one lock | Poor |
ConcurrentHashMap | Fine-grained locking per bucket, lock-free reads | Excellent |
Loading the rest of the lesson…