[concurrency-interest] DirectByteBuffers and reachabilityFence

Andrew Haley aph at redhat.com
Wed Dec 9 14:51:55 EST 2015

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
> lifetime. 

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 at this point, you may as well just stick
> reachabilityFence(this) inside the finalizer then.

Ummm, I don't understand this.


More information about the Concurrency-interest mailing list