Isn't this code totally broken with the weak volatile
interpretation?
Doron.
--- Bill Pugh <pugh@cs.umd.edu> wrote:
> OK, here is a class that implements keepAlive:
> 
> public class FinalizerHelp {
>    static volatile Object v;
>    public static void keepAlive(Object o) {
>      v = o;
>      v = null;
>      }
>    public static void getReadyToFinalize() {
>      Object o = v;
>      }
> }
> 
> The semantics we provided to ensure that finalizer
> guardians would work
> will also ensure that an object is still reachable
> if we are going to
> write a reference to that object into a global
> variable.
> 
> Because the write is a volatile write, preceding
> memory accesses can't
> be reordered with the call to keepAlive.
> 
> The one point of ugliness here is that each
> finalizer should call
> FinalizerHelp.getReadyToFinalize().
> 
> Bill
> 
> -------------------------------
> JavaMemoryModel mailing list -
http://www.cs.umd.edu/~pugh/java/memoryModel
=====
Doron Rajwan, mailto:doron@rajwan.org
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:06 EDT