Question about atomicity in ConcurrentHashMap

Gernot Neppert mcnepp02 at
Thu May 23 08:00:36 PDT 2013


while testing build 90 of JDK 1.8.0, I was pleased to see that dearly
missed methods such as 'computeIfAbsent' have now been included in
interface Map!

However, in the past, whenever I needed such a method, it would have had to
be atomic in order to be useful.

The JavaDoc of java.util.Map.computeIfAbsent clearly states:

"Any implementation providing atomicity guarantees must override this
method and document its concurrency properties."

So I'm wondering: Why does ConcurrentHashMap not implement those methods in
an atomic way?

More information about the lambda-dev mailing list