> When a finalizer is run, it is guaranteed to see all of the writes
>to the object being finalized, but not to any other object.
I think this should not cause any implementation problems. There are
A thread may not perform a compile-time reordering of two statements
s1 and s2, where s1 updates an object X and s2 makes X unreachable.
This should hold because s1 can't be executed if X is unreachable.
In between the time an object X because unreachable, and the
finalizer for X is run, the following things must happen:
* all threads that updated X must perform a memory barrier to force
their writes to X to main memory
* then, the finalizer thread must do a memory barrier before
execution so as to see all of those writes.
In any implementation I can think of, a garbage collection needs to
be performed between the point where X becomes unreachable and then
the finalizer for X is run. This will give us the global memory
barriers we need.
I suspect that Tom is right and this should all be specified in terms
of weak references. The same issues arise, I'll have to look at the
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:24 EDT