G
Gordon Beaton
How does a guy go about restarting a finished thread? I have a class
that extends thread and I want to be able to restart it once it has
finished his task. Is there anyway I can get the thread to restart
itself by say having a method which I can call. Thanks
No, you need to start a new thread. This has always been the case and
it is often repeated here, however AFAICT it wasn't until 1.5 that the
javadocs actually said so.
An alternative is to not let the thread terminate at all (i.e. don't
ever return from run()). When it's finished its task, block it in a
call to wait() until you call a custom method to reinitialize any data
and let it continue with a new task.
Note that for most uses it's considered better style to implement
Runnable than extend Thread.
/gordon