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"); } }

11th Feb 2022, 2:08 PM
Nipun
Nipun - avatar
4 Antworten
+ 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.
4th Jul 2022, 11:40 AM
Ausgrindtube
Ausgrindtube - avatar
+ 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..
11th Feb 2022, 2:29 PM
Jayakrishna 🇮🇳
0
In system its not working...can try thread.sleep r start like that
11th Feb 2022, 2:31 PM
Nipun
Nipun - avatar
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..
11th Feb 2022, 2:36 PM
Jayakrishna 🇮🇳