Thread Scheduling
- Only one thread can execute at a time.
- The Scheduler, which is part of the JVM, determines which thread gets to run.
- There is no guarantee which ready thread the scheduler will select, and your code does not
have direct control.
- There are 2 basic types of schedulers:
- round robin - used in time-sliced systems. A thread is given a small amount of processing time (called a "quantum"), then the system automatically lets other threads of the same priority run for a small amount of time.
- preemptive - a running thread completes its execution unless a higher-priority thread becomes ready. For threads with the same priority, one thread must complete before another one can run.