Can someone please provide answers for the following questions:
I understand the reason why
null
value is not allowed inConcurrentHashMap
. But why is anull
key not allowed?The concurrency level determines how many threads can concurrently access the map and the default value is 16. This means map is divided into 16 parts and lock is placed on each of the part. This works fine as long as initial capacity is also 16 so there are 16 buckets and 16 locks which works out one lock per bucket. How does this work when the initial capacity is greater than concurrency level and also in case of initial capacity lesser than concurrency level?