Is it possible to restart Thread?

Hi All !!!

I have an app which uses threads. I have class that extends class Thread. This is server/client app so when two clients connect to server, server starts this thread. It does something and then ends. My problem is that when one of clients leave and then connect again server tryes to start thread and here I have IllegalThreadStateException

. It looks like this thread started before hasnt die yet but method isAlive() returns false.

Please help. Thanks.

[489 byte] By [legolPLa] at [2007-10-3 4:23:00]
# 1

Well, this is exactly what the API docs for Thread.start() have to say about this:

"It is never legal to start a thread more than once. In particular, a thread

may not be restarted once it has completed execution."

You have already started that thread before, you can't start it a second time.

kind regards,

Jos

JosAHa at 2007-7-14 22:25:20 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks for fast answer.Now I'll read API before asking here :)
legolPLa at 2007-7-14 22:25:20 > top of Java-index,Java Essentials,Java Programming...