Whenever multiple threads are waiting to get chance for execution which thread will get chance first it is decided by Thread Scheduler. whose behavior is JVM vendor dependent . Hence we can not expect the exact execution order of multiple threads and hence output may also differ each time.

Thread Scheduler is the part of JVM (Java vitrual Machine ).

  • Let us see the example of Unpredictable nature of Thread Scheduler.

    Let us create two threads and start these two thread at the same time .

What next?

The next topic is Life Cycle of Thread in java

Share this page