[concurrency-interest] Is Reference.reachabilityFence() needed in Reference constructor?

Andrew Haley aph at redhat.com
Wed Oct 21 11:53:38 EDT 2015


On 10/21/2015 04:44 PM, Aleksey Shipilev wrote:
> Of course, this does not tell another (scary) part of the story, what if
> the Reference itself is not discovered as strong ref by GC, e.g. when it
> isn't published on heap, or scalarized by compiler, etc.
> reachabilityFence, as currently implemented, extends the "liveness"
> scope of the local variable, but does not convey anything special to the
> GC/runtime otherwise.

If the Reference itself is not reachable from a strong root then the
Reference is dead so we don't care what happens to it.  But if the
Reference is put on a reachable ReferenceQueue, then it's fine.

Andrew.


More information about the Concurrency-interest mailing list