0

JAVA: just a bug?

Hello world! I hope you will be able to get me out from this, I am lost! Did I miss something regarding the setPriority() method? The code here below works very well on my computer. Threads Pro Challenge: public class Main { public static void main(String[ ] args) { Name name = new Name(); //set priority name.setPriority(2); Welcome welcome = new Welcome(); //set priority welcome.setPriority(1); name.start(); welcome.start(); } } //extend the Thread class class Welcome extends Thread{ public void run() { System.out.println("Welcome!"); } } //extend the Thread class class Name extends Thread{ public void run() { System.out.println("Please enter your name"); } } After trying to understand why, finally, I could solve the challenge by changing the code line order of the method start(). I mean: name.start(); welcome.start(); by this: welcome.start(); name.start(); I was really happy to solve the challenge but at the end it seems me that something is wrong on this exercise that I don't understand yet. Please world, enlighten me!

21st Jan 2021, 3:18 AM
Atok
Atok - avatar
3 Antworten
+ 1
No, it is not working properly. No as per test verification on the pro challenge, I have screenshot to illustrate my doubt. I am sorry if I was not clear but when I said that it works on my computer, I meant on my IDE and not in the SoloLearn platform/app. On this exercise the setPriority() method does not work. Thanks in advance for your time!
21st Jan 2021, 3:42 AM
Atok
Atok - avatar
+ 1
Something similar to me.... https://www.sololearn.com/Discuss/2672570/?ref=app Using searching... For simple operations don't rely on threads.. It depends on OS support.. Once look at this : hope it helps.. https://www.sololearn.com/Discuss/2211828/?ref=app
25th Jan 2021, 4:59 PM
David Ordás
David Ordás - avatar
0
Your code is correct and working properly what u expecting through this code .
21st Jan 2021, 3:37 AM
A S Raghuvanshi
A S Raghuvanshi - avatar