Java Thread getPriority() Method
Example
Get the priority of the main thread:
public class Main {
public static void main(String[] args) {
Thread thread = Thread.currentThread();
System.out.println(thread.getPriority());
}
}
Definition and Usage
The getPriority() method returns the priority of a thread. The priority is a number from 1 (lowest) to 10 (highest).
The main thread has the normal priority, 5. A new thread gets the same priority as the thread that creates it.
Tip: Use the setPriority() method to change the priority of a thread.
Syntax
public final int getPriority()
Parameter Values
None.
Technical Details
| Returns: | The priority of the thread, as an int. |
|---|
Related Pages
❮ Thread Methods