RE: JavaMemoryModel: Another Java threading issue (finalization)

From: Alexander Terekhov (
Date: Wed Apr 02 2003 - 03:51:08 EST

Hans Boehm wrote:
> If objects A and B both have finalizers, A refers to B, and As
> finalizer needs to access B, there is no way to ensure that A will
> be finalized first.

Uhmm, what about the following: introduce post-constructors and pre-
finalizers and legislate that "pre-" stuff should keep invariants
intact and "optionally be prepared" for resurrection. The collector
would ensure two phase processing: the pre-finalizers for all
collected objects would run first, followed by the finalizers (or
post-constructors [kinda "resurrectors"] for the resurrected stuff).
The A's pre-finalizer would then be able to "safely access" B. The
same would also apply to B's pre-finalizer (if any) WRT A. Well,
also: < pls see (g) >

What do you think? TIA.



------------------------------- JavaMemoryModel mailing list -

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