Skip to content
Sharp

Java Threading · interview question

How does a ConcurrentHashMap handle concurrent updates to ensure thread safety?

Multiple choiceHardchapter-15-curatedpremiumjava-threadingrace-conditions
Choose one answer
Answer and explanation

Correct answer

B. It locks segments of the map rather than the entire map.

Why

ConcurrentHashMap uses a segmented locking strategy, where updates can lock only a segment of the map, allowing greater concurrency and better performance compared to locking the entire map.

Test yourself on Java Threading

A free test with instant, explained results. No account needed.

Start free test
All Java Threading questions →