[concurrency-interest] jdk9 VarHandle and Fence methods

Peter Levart peter.levart at gmail.com
Fri Aug 21 16:47:55 EDT 2015


Hi Doug,

On 08/21/2015 03:44 PM, Doug Lea wrote:
> /**
>      * Atomically sets the value to the given updated value with the
>      * memory semantics of setRelease if the current value {@code ==}
>      * the expected value, as accessed with the memory samantics of
>      * getRelease.
             ^^^^
Should that be getRelaxed or more probably getAcquire ?

> *
>      * @param expected the expected value
>      * @param val the new value
>      * @return the current value, which will be the same as {@code 
> val} if
>      * successful.
>      */
>     T compareAndExchangeRelease(Object owner, T expected, T val); 

Suppose the value is currently 1 and two threads do the following 
concurrently:

Thread1:

v1 = compareAndExchangeRelease(owner, 1, 2);

Thread2:

v2 = compareAndExchangeRelease(owner, 1, 3);



Can the outcome be: v1 == 2, v2 == 3 ?

If it is getAcquire then probably not, but if it is getRelaxed then It 
might be or not?


Regards, Peter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20150821/c4d10258/attachment.html>


More information about the Concurrency-interest mailing list