I understand that in HashMap, the entries (Key, Value) are placed in buckets based on hash(Key.hashCode)--> The index that denotes the bucket location. In case an entry is a
A bucket is an individual slot in the map's array. This is the same with both HashMap
and ConcurrentHashMap
. Conceptually, the latter has its array broken into segments (each segment is an array of references), but that's it. Note that the CHM in Java 8 no longer has segments, it's all a single array.
Yes, it's the scheme known as segmented locking. It reduces inter-thread contention, but does not eliminate it.