[concurrency-interest] Atomicity of clearing of WeakReferences
crazybob at crazybob.org
Tue Jul 14 19:46:35 EDT 2009
On Tue, Jul 14, 2009 at 4:28 PM, Joseph Seigh <jseigh_cp00 at xemaps.com>wrote:
> If you have more than one WeakReference pointing to an object, and the
> object no longer has any normal references, are the references cleared
> atomically? Or can you bring an object back into play by getting a
> reference to it from a WeakReference that hasn't been cleared after seeing a
> different WeakReference to it get cleared?
The spec says they are cleared atomically:
"Suppose that the garbage collector determines at a certain point in time
that an object is weakly
At that time it will *atomically* clear all weak references to that object
and all weak references to any other weakly-reachable objects from which
that object is reachable through a chain of strong and soft references. At
the same time it will declare all of the formerly weakly-reachable objects
to be finalizable." (
This would be easy to support in a stop-the-world collector, but it seems to
me that it could overly restrict concurrent collectors. Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest