Java Thread getPriority() method

The getPriority() method of thread class is used to check the priority of the thread. When we create a thread, it has some priority assigned to it. Priority of thread can either be assigned by the JVM or by the programmer explicitly while creating the thread.

The thread's priority is in the range of 1 to 10. The default priority of a thread is 5.

Syntax

Return

It returns the thread's priority.

Example

Test it Now

Output:

t1 thread priority : 5
t2 thread priority : 5
running thread name is:Thread-0
running thread name is:Thread-1





Latest Courses