Re: JavaMemoryModel: Finalizer question

From: Bill Pugh (pugh@cs.umd.edu)
Date: Wed Apr 21 2004 - 11:08:51 EDT


On Apr 21, 2004, at 5:24 AM, Bart Jacobs wrote:

> Personally, I like the idea of a GC.KeepAlive method, as in the .NET
> Framework.
>
> The rule would be: the finalizer for object O happens-after every
> GC.KeepAlive call for object O. (Or, more specifically: after a point
> where no GC.KeepAlive call could possibly follow if no finalizers were
> run.)
>
> So, after each access of the "global data structure" (e.g. an operation
> on the file), the programmer must insert a GC.KeepAlive call. This is
> nice, simple and explicit, and the overhead is acceptable.
>

We talked about this before. We never reached a consensus at a level
required to force an API change,
and now it is too late to add a new method to the API.

We do guarantee that you can achieve this by either synchronizing on
the object after
updating it, and synchronizing on it again in the finalizer, or
alternatively
writing to a volatile field of the object after updating it, and
reading that
field in the finalizer.

Bill

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



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