Thread getPriority() Method In Java Example
Chapter:
Thread
Last Updated:
11-04-2016 17:07:11 UTC
Program:
/* ............... START ............... */
public class JavaThreadGetPriority implements Runnable {
Thread t;
JavaThreadGetPriority() {
t = new Thread(this, "Admin Thread");
// set thread priority
t.setPriority(1);
System.out.println("thread = " + t);
t.start();
}
public void run() {
System.out.println("Thread priority = " + t.getPriority());
}
public static void main(String args[]) {
new JavaThreadGetPriority();
}
}
/* ............... END ............... */
Output
thread = Thread[Admin Thread,1,main]
Thread priority = 1
Notes:
-
The java.lang.Thread.getPriority() method returns this thread's priority.
Tags
Thread getPriority() Method, Java