[concurrency-interest] conditional put

David Holmes dcholmes at optusnet.com.au
Mon Nov 5 21:49:17 EST 2007


Dhanji,

I can think of some ugly tricks to get the Callable evaluated only if being
placed into (or potentially placed into) the map; but there is no way to do
this "atomically".

David Holmes

> -----Original Message-----
> From: concurrency-interest-bounces at cs.oswego.edu
> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Dhanji
> R. Prasanna
> Sent: Tuesday, 6 November 2007 12:28 PM
> To: concurrency-interest
> Subject: [concurrency-interest] conditional put
>
>
> 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.
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest



More information about the Concurrency-interest mailing list