Thread Priorities in Java

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

Threading Basics

Thread Safety in Java

Thread Communication in Java

Join() method in Multit-Threading

The yield() method

The sleep() method

Daemon Threads in Java

Thread pool executor in java

Thread pools in Java

Thread Dead lock in Java

Thread Live lock in Java

2 thoughts on “Thread Priorities in Java

  1. biorornanna Reply

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *