do we need separate thread for FirstThread
Cedric Berger
cedric@wireless-networks.com
Thu Feb 8 16:37:00 GMT 2001
Per Bothner wrote:
>
> Bryce McKinlay <bryce@albatross.co.nz> writes:
>
> > > * Avoid creating threads in single-threaded programs.
> >
> > Well, we can't really do this, since a separate finalization thread (for
> > example) will be required in order to implement finalization correctly.
>
> I'm missing something here. The JLS says finalizer are run in an
> "unspecified" thread. There seem to be two logical alternatives:
> (1) a special finalizer or gc thread, or
> (2) the thread that causes gc to be invoked (by doing a new).
> Why is (2) prohibited?
(2) is prohibited in a multithreaded application because of risks
of deadlock.
Of course, if you're sure you have only one thread running, (2) is
valid.
Cedric
More information about the Java
mailing list