[concurrency-interest] ConcurrentHashMapV8

Doug Lea dl at cs.oswego.edu
Tue Aug 30 19:22:43 EDT 2011


On 08/30/11 16:52, Zhong Yu wrote:
> Thanks for clarifying the intended usage for me. Still, given the
> heavy restriction on the function, I can't grasp the usefulness of the
> method without a realistic use case.

We didn't support computeIfAbsent before, for the
kinds of reasons you list. But the compelling reason
for including it anyway is error avoidance. An upcoming paper
in OOPSLA 2011 examined usages of ConcurrentHashMap in real-world
code, and found that by far, the most common error was
incorrect use of putIfAbsent in cases covered by computeIfAbsent.
Adding computeIfAbsent now may be too little, too late, but even this
is only made easily usable with lambda syntax. We do expect
to see some usages that don't follow advice and generate
occasional performance anomalies, which is a lot better than
people occasionally getting it completely wrong.

-Doug



More information about the Concurrency-interest mailing list