Solving a problem in Sololearn Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Solving a problem in Sololearn Java

Hey! Please help me solve the problem: in the Sololearn application this code does not work correctly, but in the JDE IntelliJ IDEA this code works and calls methods by priority. class Main { public static void main(String[ ] args) { Name name = new Name(); //установить приоритет name.setPriority(1); Welcome welcome = new Welcome(); //установить приоритет welcome.setPriority(10); name.start(); welcome.start(); } } //расширить класс Thread class Welcome extends Thread{ public void run() { System.out.println("Welcome!"); } } //расширить класс Thread class Name extends Thread{ public void run() { System.out.println("Please enter your name"); } }

8th Feb 2021, 10:38 AM
Александр Дегтярев
Александр Дегтярев - avatar
1 Answer
0
I believe this is an application problem. If you want to solve the problem, just swap the calls to the welcome.start () and name.start () methods. class Main { public static void main(String[ ] args) { Name name = new Name(); //установить приоритет name.setPriority(1); Welcome welcome = new Welcome(); //установить приоритет welcome.setPriority(10); welcome.start(); name.start(); } } //расширить класс Thread class Welcome extends Thread{ public void run() { System.out.println("Welcome!"); } } //расширить класс Thread class Name extends Thread{ public void run() { System.out.println("Please enter your name"); } }
8th Feb 2021, 1:39 PM
Александр Дегтярев
Александр Дегтярев - avatar