Changing Thread Priorities
As mentioned previously, multiple threads compete for CPU time. There are various algorithms used by the operating system and Java VM when figuring out which thread should be executed next. Thread scheduling can be divided into two main types: preemptive and non-preemptive. Java native threads usually support the preemptive model. This means that the schedule interrupts the current thread when its time for the processor runs out. With Java green threads, the non-preemptive model is normally used. This model allows the thread to continue until the thread yields control. However, even with the non-preemptive model, if a higher priority thread is ready to execute, the current thread has to give up the CPU.
The discussion ...
Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.