How can we prioritize the thread properly in java ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can we prioritize the thread properly in java ??

4th May 2018, 5:43 AM
Mohit Aggarwal
Mohit Aggarwal - avatar
1 Answer
+ 1
You can set priorities to threads before starting them using setPriority() which takes a constant between 1 and 10 Or simply MIN_PRIORITY for 1 NORM_PRIORITY for 5 (this is default) MAX_PRIORITY for 10 for example: thread t1 can be given maximum priority by t1.setPriority(MAX_PRIORITY) or t1.setPriority(10)
4th May 2018, 9:00 AM
Uday
Uday - avatar