I don't believe there's a sound technical reason why they couldn't have made it possible to start a Thread again; it's just a simple model that works well in practice. The Thread class is implemented mostly in native methods; on modern JVMs these are implemented by calling out to the native platform's thread library.
Juggy, your "firm belief" does not reflect reality. Yes, Java's designers probably could have designed Threads this way. But they didn't. If you call start() a second time, you will get an IllegalThreadStateException. A dead thread does not have the same state as a new thread.
Now I'm just guessing, but I think the reason for this might be that they wanted to make it easier for the thread scheduler to immediately free up some of the thread resources as soon as a thread terminates. I'm not talking about the Thread object, which will exist on the heap for as long as there's a reachable reference in memory somewhere. But there should be additional resources which are accessible only in native code, and for efficient thread scheduling these should probably be freed as soon as possible, without necessarily waiting for garbage collection.
"I'm not back." - Bill Harding, Twister
Joined: Oct 30, 2001
Originally posted by Juggy obhi: I firmly believe that after a successful execution of run() the Thread instance comes back exactly where it started from...so i don't see any good reason why start() can't be called again.
I believe that there is rarely much to be gained by worrying about why Java does or doesn't have some or other feature. Occasionally, it will be enlightening, but in this case, and many others, it isn't.
They could have done it how you suggest, but they didn't. It's still possible to implement re-runnable tasks, using Runnable, so no important tools are being denied you.
Move on please, nothing to see here...
Joined: Jul 02, 2007
Jim,Peter,Thanks for clarifying my doubt...You are right that Dead Thread(on which you can't call start())is not exactly New Thread(on which you can call start()).
And your guess is respectable as well.
It's was a bit strange for me to encounter with an Object that allows you to call its member function for single time only. [ July 23, 2007: Message edited by: Juggy obhi ]