Posted By:
Anonymous
Posted On:
Thursday, August 23, 2001 05:15 PM
Few comments:-
1) your code will never compile because of
while (1)
After you have modify your code,
2) run() will definitely execute the second time but this time, it is running under the context of the main thread.
To prove this:- modify your statement in the run() to show which thread is running under.
System.out.println (Thread.currentThread()+" is running");
3) your code is buggy, instead of the first thread (MyThread) stops executing, there will be two run being executed (modify 1 and retest).
The reason: your while (true) will never break up from the loop.
Having said all these, it would take you just 30 seconds to find out all the above. Next time, do take the time to experiment! :-)