Skip to content

What is thread priority in Java?

Niklas edited this page Jun 10, 2021 · 1 revision

Priority of a thread describes how early it gets execution and selected by the thread scheduler. In Java, when we create a thread, always a priority is assigned to it. In a Multithreading environment, the processor assigns a priority to a thread scheduler. The priority is given by the JVM or by the programmer itself explicitly. The range of the priority is between 1 to 10 and there are three constant variables which are static and used to fetch priority of a Thread. They are as following:

  • MIN_PRIORITY = It holds the minimum priority that can be given to a thread. The value for this is 1. -> EugeneFactoryPriority.MIN
  • NORM_PRIORITY = It is the default priority that is given to a thread if it is not defined. The value for this is 5. -> EugeneFactoryPriority.NORM
  • MAX_PRIORITY = It is the maximum priority that can be given to a thread. The value for this is 10. -> EugeneFactoryPriority.MAX
  • declaration by studytonight
Clone this wiki locally