Java Thread Priority


After knowing how to create and run threads and heavy and light weight threads, it is the time to prioritize threads.

A thread in Java can be given a priority within the range from 1 to 10. If no priority is given, the thread takes a default priority of 5. Two methods exist in Thread class to give and retrieve the priority of a thread – setPriority() and getPriority().

The following program illustrates on thread priorities. To differentiate the threads, setName() and getName() are also used to set a name to a thread and retrieve the name of a thread.

Thread Priorities

For all programs on multithreading

Multithreading at a Glance

1 thought on “Java Thread Priority”

Leave a Comment

Your email address will not be published.