Java Thread.getPriority()

Syntax

Thread.getPriority() has the following syntax.

public final int getPriority()

Example

In the following code shows how to use Thread.getPriority() method.


//  ww w.  j  ava 2  s.c o m
class ThreadDemo extends Thread{
  public void run() {
    System.out.println("Thread priority = " + getPriority());
  }
}

public class Main {
  public static void main(String args[]) {
    Thread t = new Thread(new ThreadDemo(), "java2s.com thread");
    t.setPriority(1);

    System.out.println("thread  = " + t);

    t.start();
  }
}




















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable