Java- Thread setPriority does not ensure order of execution right? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java- Thread setPriority does not ensure order of execution right?

I was doing a java practice about Threads in Java, where you had to reverse the order of two instances of an extended Thread class. You had to .setPriority() to get the reverse order but it didn't work.

18th Apr 2023, 9:29 PM
Erik Francesco
2 Answers
+ 5
What Sololearn's compiler does and the way things act in the real world are different some times. As per that other forum thread, there are circumstances that also come into play.
19th Apr 2023, 6:49 AM
Ausgrindtube
Ausgrindtube - avatar
+ 3
Right, there is no guarantee. We discussed it here a bit: https://www.sololearn.com/discuss/3206427
18th Apr 2023, 10:33 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar