RE: JavaMemoryModel: Another Java threading issue (finalization)

From: David Holmes (dholmes@dltech.com.au)
Date: Tue Apr 01 2003 - 19:40:22 EST


Paul Jakubik wrote:
> My understanding of what has been proposed in this thread is
> that the developer should do the following:
>
> If your class has a finalizer you must synchronize any
> potential last-method-call and the finalizer.
>
> If I understand this correctly, this sounds like bad news for
> library developers. It would mean that every method and the
> finalizer should be synchronized (at least every public
> method). The library would be made significantly slower in
> hopes of allowing an optimization to make the library a little
> faster.

That's my current understanding. *if* you could tell which was the
last method call then you might be able to do something less
restrictive, but otherwise ...

Perhaps there are alternative idioms for "finalization " that might be
able to utilise a combination of the volatile/final semantics and the
use of the reference classes??

Arguable, as a library developer, you should just stay away from
finalizers - they're evil don't you know :-)

David Holmes

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



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