[concurrency-interest] jdk9 VarHandle and Fence methods

Andrew Haley aph at redhat.com
Fri Sep 4 04:40:25 EDT 2015

On 09/04/2015 05:10 AM, David Holmes wrote:

> I see your point but I’d consider these at two different levels of
> abstraction. CAS, as a primitive, is easier to reason with if it has
> the ordering guarantees even on failure. I can easily imagine
> CAS-based algorithms that require such guarantees even if the CAS
> fails.

In which case it makes sense to insert them explicitly.  There's no
reason not to follow a CAS with a full fence if one is really needed
on failure.  That will make the code easier to read.

It's trivial to take out the trailing fence in the JIT if some
hardware does a full fence on a failed CAS.


More information about the Concurrency-interest mailing list