Re: JavaMemoryModel: Finalization idioms

From: Thomas Hawtin (tackline@claranet.com)
Date: Mon May 02 2005 - 17:33:23 EDT


Boehm, Hans wrote:
>
> 1) Make all methods which might be the last ordinary call on an
> object synchronized. Make the finalizer synchronized.
>
> 2) Write to a volatile field at the end of ordinary methods,
> and read it first thing in the finalizer.
>
> 3) Put "synchronized(this){}" at the end of ordinary methods and at
> the beginning of finalizers.

Presumably to be absolutely correct 2 & 3 would need to be in finally
blocks, although any problems would be incredibly obscure.

I'm trying to work out anyway to make PhantomReferences behave
reasonably. Any technique to keep the object object alive is going to be
invisible to the ReferenceQueue handler.

Tom Hawtin
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:10 EDT