[concurrency-interest] DirectByteBuffers and reachabilityFence
aph at redhat.com
Wed Dec 9 15:06:02 EST 2015
On 12/09/2015 07:51 PM, Andrew Haley wrote:
> On 12/09/2015 07:20 PM, Vitaly Davidovich wrote:
>> I don't see how this extends the lifetime of the object unless, at minimum,
>> you increment the counter at each operation where you want to extend the
> Yes, you do increment the counter at each operation. There has to be
> a use of the counter in the finalizer to keep it alive. Thinking
> about it some more though, even this may not be enough in the presence
> of some very aggressive optimizations because there is no
> happens-before relationship between the methods and the finalizer.
And without a fence there's nothing to stop the counter update
moving past the Unsafe operation. So no, this won't really
work without at least a compiler barrier.
More information about the Concurrency-interest