Overview

Chapter 6 - Thread Prioritization

Java Thread Programming
Paul Hyde
  Copyright 1999 Sams Publishing

Priorities and Scheduling
The virtual machines thread scheduler determines which thread is currently running on the processor and how long it is allowed to run before being swapped off the processor to allow another thread to run. Thread priorities provide additional information to the thread scheduler as to which threads are more important to run.
Generally, higher-priority threads get more processor time than lower-priority threads. The Java Language Specification does not require any more specific scheduling selection than this. In particular, a low-priority thread may not run until all of the threads with a higher priority are blocked (sleeping, waiting on I/O, or some other blocked condition). It is likely (but not guaranteed ) that a low-priority thread will be swapped off the processor as soon as a higher-priority thread unblocks and becomes ready-to-run. Threads of equal priority may or may not share the processor with each other. In addition, most VM implementations use the underlying operating systems threads. Exact thread behavior varies from VM to VM, and you need to be careful that your designs do not critically depend on one particular implementation.
  Caution Thread priorities are only a suggestion to the thread scheduler and should not be used to guarantee program correctness. Write your programs in such a way that they would still produce correct results regardless of prioritization.

Toc


Java Thread Programming
Java Thread Programming
ISBN: 0672315858
EAN: 2147483647
Year: 2005
Pages: 149
Authors: Paul Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net