Skip to content
Veltoryx Technologies
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

OptionHow it's thread-safeThroughput under load
Hashtable (legacy)Every method synchronised on one lockPoor
Collections.synchronizedMap(map)A wrapper with one lockPoor
ConcurrentHashMapFine-grained locking per bucket, lock-free readsExcellent

Loading the rest of the lesson…