Helo! Scheduler moves in mysterious ways and gives the thread of the MyThread more Running state than the "spawned" threads. There are, however, some means to control this. You might want to place Thread.yield() right after the start method of the other threads. Keyword synchronized might help to keep the code running in the run() method. Thats it in the nutshell. For detailed explanation see some good text book or wait for some Java guru to notify this topic. ------------------ Antti Barck It Solutions Consultant, NSD Oy
Muhammad I assume you mean why does it look like the two threads are not starting until after the 'End of main' message appears. The Threads do not actually start when you call the start method. start does some behind the scenes work to make the Thread able to run in its own process and registers the Thread with the scheduler. It is the scheduler that decides when a thread is allocated cpu time. In this case the scheduler lets the main method finish running before it gives the cpu to either of the other two. If you put some other code into the main (like a loop or something else that takes a few seconds) you may see the other two threads print their messages before main does. You could also try to increase the priority of the two threads and see if the scheduler behaved differently. No one specific outcome is guaranteed in a situation like this. Some of it is system dependent and some is dependent on the implementation of the JVM.
hope this helped you out
Dave [This message has been edited by Dave Vick (edited July 25, 2001).]