Skip to content

Concurrency level? #852

Answered by ben-manes
brent-holland asked this question in Q&A
Discussion options

You must be logged in to vote

tldr; it is a no-op option since Java 8, so it is not exposed

In Java 5's ConcurrentHashMap, the table was statically divided into segments based on the concurrencyLevel (adjusted to a power-of-two). This was used to lock the entire segment when writing an entry that hashed into it, which led to coarse grained locking. A read is lock-free by volatile reads of a immutable snapshot linked list, so it could walk that safely. This resulted in good performance in general, but writes did not scale very well and it did not offer rich per-entry computations as it would lock too broadly. Guava adapted that by (effectively) storing a future as the entry value so that the hash table operations stay …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ben-manes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants