javatutelearn.com
Easy Learning
Search Javatutelearn.com :
Java Virtual Machine (JVM) consists of thread scheduler. It decides which thread should be executed on the machine.
Thread Scheduler uses two types of scheduling:
(a) Pr-emptive scheduler
(b) Time slicing scheduler
(a) Preemptive scheduling: -
In this scheduling, the highest priority thread executes. When it goes to waiting state or another higher priority task comes into existence,
then another thread gets chance for the execution.
(b) Time slicing scheduling: - A time slice is allotted to the thread. When time slice is exhausted, then another thread gets chance for execution for its time slice.
public class test1 extends Thread { public void run() { System.out.println("Running..."); } public static void main(String args[]) { test1 t1 = new test1(); t1.start(); t1.start(); } }