✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Результат компіляції програмного коду:
public class NewThreadThree implements Runnable {
String name;
Thread t;
NewThreadThree (String threadname){
name = threadname;
t = new Thread (this, name);
t.start();
}
public void run() {
try {
System.out.println("Виконання потоку "+ name);
Thread.sleep(200);
}catch (InterruptedException e) {
System.out .println(name + " перервано");
}
System.out .println(name + " завершено");
}
}
public class NewThreadThreeMain {
public static void main(String[] args) {
new NewThreadThree("Один");
new NewThreadThree("Два");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println("Головний потік перервано");
}
System.out.println("Головний потік завершено");
}
}