Here i thought in the run method super.start() will invoked the Thread class's run method which does nothing ...but to my suprise i got an exception mentioning we cannot restart a thread.
But if im not wrong if i put something like this.start(), then certainly an exception would come but how come super.thread() is same as invoking the present thread again.
Here i thought in the run method super.start() will invoked the Thread class's run method which does nothing ...but to my suprise i got an exception mentioning we cannot restart a thread.
But if im not wrong if i put something like this.start(), then certainly an exception would come but how come super.thread() is same as invoking the present thread again.
Pls help.im taking my 1.5 exam tommorow...
Since you never overriden the start() method, there is no real difference between this.start() and super.start(), they both call the thread object's start() method... but to answer your question...
In your main method, you created the thread object and call the start() method, which creates the thread which calls the run the method. In your run() method, you are trying to restart the same thread, which has already been started, hence the exception.
After all, if the thread wasn't already started, then how did the start() method of your run() method even got called??
BTW, I wasn't implying that it was a good idea to override the start() method, from my answer.