On Thu, 15 Jun 2006 00:45:02 +0300, "Jusa Saari"
<jargonautti at hotmail.com> said:
> > Also the point about starting threads in constructors in non-final classes
> > may impact us. It is also possible that some code violates this:
> 
> Uh oh. I've seen code that started threads from constructors (in FreeCol)
> break (begin throwing NullPointerExceptions) just by changing the garbage
> collector, and begin functioning properly when I fixed the code (moved
> the
> thread starting into another method and changed all places that created
> objects into looking like "new SomeObject().startThreads()").

It is definitely unwise to start threads from within constructors, I
have also run into unpredictable and difficult-to-debug problems when
doing that (IIRC its something to do with the order in which values are
assigned to instance variables).

I generally use the .init() method described later in this thread.

Ian.

Reply via email to