What are the three types of priority ?

What are the three types of priority ?

Every thread in java has some priority. The valid priority range is 1 to 10, where 1 is the least and 10 is the max priority.
The Thread class defines the following constants to set some standard priorities:
1) Public static final int MIN_PRIORITY (1)
2) Public static final int NORM_PRIORITY (5)
3) Public static final int MAX_PRIORITY (10)
The thread with highest priority may get (cannot guarenteed) the chance of first execution.
Two threads have the equal priority, we cannot determine which thread will be executed first.
Thread class defines following methods to get and set the thread priorities:
1) Public final int getPriority()
2) Public final void setPriority(int priority)
Default Priority
By default, every thread is set with default priority which is 5.
The default priority of the main thread is also 5.

By:Sumit Tripathi
Date:2021-05-15 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher