What are the different types of Thread Priorities in Java? And what is the default priority of a thread assigned by JVM?
In Java, the Thread class provides thread priorities that allow you to assign relative importance to threads. Thread priorities are represented by integer values ranging from 1 to 10, where 1 is the lowest priority and 10 is the highest priority. The thread priorities are defined as constants in the Thread class:
- Thread.MIN_PRIORITY: Represents the minimum thread priority (1).
- Thread.NORM_PRIORITY: Represents the default thread priority (5).
- Thread.MAX_PRIORITY: Represents the maximum thread priority (10).
The default priority of a thread assigned by the JVM is Thread.NORM_PRIORITY (5). It is worth noting that the thread priority does not guarantee strict execution order or fairness. It is merely a hint to the thread scheduler regarding the relative importance of a thread.
