Grokking Java Interview Questions
Vote

0% completed

​

ConcurrentHashMap and Concurrent Collections

Two threads call put() on the same empty ConcurrentHashMap of 16 buckets at the same moment, one with the key "banana" and the other with "mango". How many locks does the map take? The answer is none, because the two keys go to different buckets, and each bucket is empty. If the keys are "apple" and "cherry", which go to the same bucket, the second thread needs one lock.

The lesson Unmodifiable, Immutable, and Synchronized Collections compared this map with two older ones

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content