Thread Priorities in Java
If there are multiple threads in an application , then those threads reaches to the ready to run state based on thread priority.JVM contains a thread scheduler and it is managing the threads based on priorities. Priority is represented by an integer value from 1 to 10. A priority value of 1 means that thread is having the minimum priority value.A priority value of 10 means it has the maximum priority value. The default priority value is 5 .
In program it is possible to change the priority value using setPriority(int value) method of Thread class.Also there are constants to specify the priority value .Thread.MIN_PRIORITY , Thread.MAX_PRIORITY , Thread.NORM_PRIORITY are integer values 1 , 5 and 10.
But it is not preferable to develop multi-threaded applications by trusting the priority values . The behavior is different in different platforms and in different JVMs.
See Related Discussions
Join() method in Multit-Threading
2 thoughts on “Thread Priorities in Java”
I’m impressed, I need to say. Truly rarely do I encounter a blog that’s both educative and entertaining, and let me tell you, you have hit the nail on the head. Your idea is outstanding; the problem is some thing that not enough folks are speaking intelligently about. I’m fairly happy that I stumbled across this in my search for some thing relating to this.