0
Why the set property not working.?how to declare it???!!!!!!!!....//when we change printing statmnts thn it'll correct🤓😅
class Main { public static void main(String[ ] args) { Name name = new Name(); //set priority name.setPriority(1); Welcome welcome = new Welcome(); //set priority welcome.setPriority(2); name.start(); welcome.start(); } } //extend the Thread class class Welcome{ public void run() { System.out.println("Welcome!"); } } //extend the Thread class class Name{ public void run() { System.out.println("Please enter your name"); } }
4 Answers
+ 2
I have just swapped the start() methods over to achieve the desired result.
I'll report the task to Sololearn, see if they change it somehow.
+ 1
Priority is checked when more threads comes to execution at same time.
Your any thread will complete in less than nano second before other thread starts.
Also threads execution work depends on OS too.
Try in system, I think it won't work here.
Hope it helps..
0
In system its not working...can try thread.sleep r start like that
0
Yes. Use more threads. Start all at same time, it should have dealing with resources, just simple statements will not take time. Use thread.sleep() on all at same time. Resume at same. And see..