[concurrency-interest] DirectByteBuffers and reachabilityFence

Justin Sampson jsampson at guidewire.com
Wed Dec 9 16:26:50 EST 2015

David Holmes wrote:

> By having construction happen-before finalization, it ensures that
> if finalization happens after construction is complete then it
> will see all of the constructed values, even though they happened
> in a different thread. This is normal happens-before with regard
> to two synchronization actions – but a construction is not a
> synchronization action it was special-cased.

Program order implies happens-before order within each thread. If
the completion the constructor happens-before the execution of the
finalizer, then every write in the constructor is visible to every
read in the finalizer, and no writes in the finalizer are visible to
any reads in the constructor. Therefore if the finalizer closes a
resource, the constructor can't see that resource as closed. Any
additional synchronization actions in either the constructor or the
finalizer have to be consistent with that happens-before ordering,
because happens-before is transitive. Right?


More information about the Concurrency-interest mailing list