[PATCH]: natThread.cc: Destroy join sync objects in finalizer
Tom Tromey
tromey@redhat.com
Mon Sep 13 13:20:00 GMT 2004
>>>>> "Hans" == Hans Boehm <Hans.Boehm@hp.com> writes:
Hans> In this case, is it possible to invoke the cleanup code from
Hans> a java.lang.Thread finalizer? Is java.lang.Thread allowed to have
Hans> a finalizer?
It can have a finalizer, but user code can override it. So, there's
no guarantee it will be run.
A PhantomReference seems to be the most reliable way to do cleanup in
this situation. We could point it at the Thread object, then do
cleanup from a watching ReferenceQueue. This way the cleanup code
will only be called once the Thread (and its native data) are
irrevocably dead.
We could also just clean up the native state when the thread dies.
That is probably even better.
I filed this as PR 17438.
Tom
More information about the Java-patches
mailing list