[concurrency-interest] generalise computeIfAbsent() for ConcurrentMap

Aleksey Shipilev aleksey.shipilev at gmail.com
Wed Jun 20 12:07:05 EDT 2012


On Wed, Jun 20, 2012 at 7:51 PM, Doug Lea <dl at cs.oswego.edu> wrote:
> On 06/20/12 11:26, Aleksey Shipilev wrote:
>> Yes, I saw that coming. Continuing on my point, if computeIfAbsent()
>> ought to be the placeholder for the usual code people do around
>> putIfAbsent(), it seems to be presumed mapper function is side-effect
>> free.
>
> That was part of our reasoning for not including these methods
> in the first place. But we now know that many users disagree.

Thanks. So, no-side-effects requirement is too strict for this case
(apart from being generally unenforceable in Java), and actually
devalvates the benefit of having computeIfAbsent() as the separate
method.

-Aleksey.


More information about the Concurrency-interest mailing list