Java / Concurrent collections
How does ConcurrentHashMap achieve thread-safety?
Concurrent collections allow concurrent reads and writes without wrapping a synchronized collection. ConcurrentHashMap is the usual default map.
ConcurrentHashMap achieves thread-safety by dividing the map into segments and locking only the segment which requires instead of locking the whole map. It achieves thread-safety using locking but it performs better because it never locks the whole map.
This technique is also known as lock stripping.
More Related questions...