[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:07:39 EDT 2014
On 09/04/2014 10:17 PM, vikas wrote:
> I just wanted to know if there is any kind of synchronization/happens before
> guarantees with
> unsafe.putOrderedObject(data) and normal read of that particular data.
In general, not. In C++/C11 terms, putOrderedObject provides
a release-mode write, that must be paired with an acquire-mode
read, which you can do via getObjectVolatile if not already volatile.
There are a few special cases where you do not need this because
of some other dominating volatile reads/writes, but they are not common.
More information about the Concurrency-interest