Skip to Main Content
Java
book

Java

by Michael Sikora
January 2003
Beginner to intermediate content levelBeginner to intermediate
150 pages
7h 28m
English
Morgan Kaufmann
Content preview from Java
160
Chapter 10: Threads []
10.3 Thread Priorities
By default, a thread inherits its priority from the program or thread that created it. It is possible
to set a thread's priority using the Thread. setPriority method. A runnable thread with the
highest priority is chosen first for execution. The setPriority method takes a value between
Thread.MIN_PRIORITY and Thread.MAX_PRIORITY as an argument.
For example, in RunThreads, if we were to add the following statements prior to starting
the threads:
threadl, setPriority(Thread.MIN_PRl0RITY) ;
thread2, setPriority(Thread.MAX_PRIORITY) ;
the result would be to output the thread2
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Programming

Java Programming

Poornachandra Sarang
JAVA Programming

JAVA Programming

K. Rajkumar
Java Programming

Java Programming

Hari Mohan Pandey
Java 9 for Programmers

Java 9 for Programmers

Paul J. Deitel, Harvey Deitel

Publisher Resources

ISBN: 9781558609099