This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: do we need separate thread for FirstThread
"Boehm, Hans" <hans_boehm@hp.com> writes:
> It is prohibited. See the description of java.lang.Object.finalize: "...
> the thread that invokes finalize will not be holding any user visible locks
> ..." . That precludes the allocating thread.
It precludes the allocating thread, if it holds a lock. It would also
seem like it might preclude an existing finalizer thread. I.e. if a
finalizer thread is still running (I assume this is possible) when the
next gc invocation wants to run finalizers, it may have to start a new
finalizer thread. So you either start a new finalizer thread each
time you run finalizers, or if you re-use an existing thread, you
still have to start up a new thread if the old finalizer thread is
still running (and may have active locks). In that case you could use
the new-invoking thread, if you can cheaply determine that it holds no
locks, and start a new finalizer thread otherwise. Correct?
(I'm not saying this would be a good thing to do ....)
In any case, I'm not (any more) proposing that we should re-use the
allocating thread for finalizers. Having a separate finalizer thread
shouldn't conflict with the goal of using the initial thread as the
Java 'main' thread.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/