[concurrency-interest] conditional put

Joe Bowbeer joe.bowbeer at gmail.com
Tue Nov 6 01:00:42 EST 2007


On Nov 5, 2007 6:28 PM, Dhanji R. Prasanna wrote:
> Hi,
>
> CHM is a wonderful abstraction for atomic conditional puts
> (putIfAbsent). However, it does not work well in a lambda-like use
> case (i.e. evaluate if absent).
>
> Is there some way for me to achieve the following:
>
> chm.putIfAbsent(key, new Callable<Value> {
>     //expression that is only evaluated if key is absent
> });
>
> And that this callable is evaluated atomically.
> Thank you,
>
> Dhanji.
>

There was a long discussion about this not too long ago titled "Adding
a createIfAbsent() API?"

Have you ruled out the use of Futures (a la Memoizer)?

--
Joe Bowbeer

Remember Remember the Fifth of November...


More information about the Concurrency-interest mailing list