We know that ConcurrentHashMap can provide simultaneous access to multiple threads to improve performance, and segments are synchronized inside this class (am I right?). The question is, can this design guarantee flow safety? Say we have 30+ threads that access and modify the object associated with the same key in the ConcurrentHashMap instance, in my opinion, they still have to line up for this, right?
From my recollection that the book "Java Concurrency in Practice" says that ConcurrentHashMap provides parallel reading and a decent level of parallel writing. in the above scenario, and if my guess is correct, the performance will not be better than using Collection Api's static synchronization wrapper?
Thanks for the clarification, John.
source
share