[concurrency-interest] jdk9 VarHandle and Fence methods

thurstonn thurston at nomagicsoftware.com
Fri Aug 21 19:39:48 EDT 2015


So the current Java 8 JavaDoc has the following in the atomic package:

"compareAndSet and all other read-and-update operations such as
getAndIncrement have the memory effects of both reading and writing volatile
variables."

So it's been decided to essentially replace that with the  following?:

 /**
      * Atomically sets the value to the given updated value with the
      * memory semantics of setVolatile if the current value {@code ==}
      * the expected value, *as accessed with the memory semantics of
      * getVolatile.  *

I find that confusing/awkward (maybe it's just me), but I realize it's
tricky, and so if others don't then fine

Also, 
"(Note: on X86 and Sparc, all flavors of CAS map to the same *instruction*,
but they may all differ on ARM and POWER.) "

Just to be clear, that instruction is (LOCK) CMPXCHG and requires no before
or after fences, right?



--
View this message in context: http://jsr166-concurrency.10961.n7.nabble.com/jdk9-VarHandle-and-Fence-methods-tp12666p12675.html
Sent from the JSR166 Concurrency mailing list archive at Nabble.com.


More information about the Concurrency-interest mailing list