Thread Priorities in Java

In java, when two or more than  two thread is computing for CPU time, every thread is assigned a priority value. A highest Priority thread get preference over lower priority thread.  

All Java threads have a priority in the range 1-10.

Top priority is 10, lowest priority is 1.Normal priority ie. priority by default is 5.

Thread.MIN_PRIORITY –      1      minimum thread priority

Thread.MAX_PRIORITY –     10    maximum thread priority

Thread.NORM_PRIORITY –  5      maximum thread priority

Whenever a new Java thread is created it has the same priority as the thread which created it.

Thread priority can be changed by the setPriority() method.

Example: Write a program to demonstrate the thread priority.