O'Reilly logo

Special Edition Using Java 2 Standard Edition by Geoff Friesen, Chuck Cavaness, Brian Keeton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required