This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: do we need separate thread for FirstThread


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]