|
The thread cannot start running (doing its job specified in its run method) immediately after you call its start() method. Note that any computer process needs CPU to execute. Similarly every Java thread needs JVM to execute. In our example, one thread (the main thread) is already running. We can safely assume that there is only one JVM running on the machine where your Java program is running. Therefore as there is only one JVM, only one thread can run at a time. In the example, two thread-of-execution are coexisting at the same time. Then which one will get the turn to execute on JVM? How long it can keep executing? What will happen to the other thread? JVM has a thread scheduler, which has the ultimate say for all these questions.