To keep track of the current state of the applet, the boolean variable suspended is used. Distinguishing the different states of an applet is important because some methods will throw exceptions if they are called while in the wrong state. Scheduling Java has a Thread Scheduler that monitors all running threads in all programs and decides which threads should be running and which are in line to be executed. There are two characteristics of a thread that the scheduler identifies in its decision process. One, the most important, is the priority of the thread, the other is the daemon flag.
New threads inherit the priority and daemon flag from the thread that created it.
The scheduler determines which thread should be executed by analyzing the priorities of all threads. Those with the highest priority are allowed execution before any lower priority threads. The scheduler can be of two flavors, preemptive or non-preemptive. Preemptive schedulers give a certain time-slice to all threads running on the system. Non-preemptive schedulers decide which thread should run and run it until the thread is complete.