[concurrency-interest] Happens Before guarantee in case of unsafe.putOrderedObject and corresponding nomal read of a variable
dl at cs.oswego.edu
Fri Sep 5 07:42:21 EDT 2014
On 09/05/2014 07:31 AM, Andrew Haley wrote:
>>> While we have this particular box open, do you know why
>>> AtomicIntegerFieldUpdater.putOrderedInt() uses Unsafe.putOrderedInt() ?
>>> That one always baffles me. I would have thought it was just a store.
>> Because the underlying field must be volatile, at implementation level,
>> the VM would otherwise generate the heavier full volatile store.
> Argh. My question was meant to be about lazySet(), sorry.
> And again: I thought the idea of lazySet was to *weaken* the guarantee.
> Otherwise I don't know what it is for.
There are three basic strengths of write: Relaxed (normal),
releasing, and SC volatile. I got talked into naming the second
releasing version "lazySet" which is confusing enough, but
compounded by the almost equally odd internal unsafe name "ordered".
These should be less confusing in JDK9 when we provide more
uniform enhanced-volatile support.
More information about the Concurrency-interest