Друзья, Help!
Не проходит условие "Нить 4 из списка threads должна реализовать интерфейс Message".
Вот ни в какую.
public void run() {
while (stopper) {
this.stop(); ( или this.interrupt(); ) ( или break; )
}
}
Если буквально смотреть задание, то через this.stop(); - нить (метод ран) завершается, но условие все равно не принимается валидатором.
package com.javarush.task.task16.task1632;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Клубок
*/
public class Solution {
public static List<Thread> threads = new ArrayList<>(5);
static {
// Thread thr1 = new Thread(new MyInfinityThread());
threads.add(new Thread(new MyInfinityThread()));
// Thread thr2 = new Thread(new MyInterruptedExceptionThread());
threads.add(new Thread(new MyInterruptedExceptionThread()));
// Thread thr3 = new Thread(new MyHoorayThread());
threads.add(new Thread(new MyHoorayThread()));
// Thread thr4 = new Thread(new StopIfWarning());
threads.add(new Thread(new StopIfWarning()));
// Thread thr5 = new Thread(new ReaderMethod());
threads.add(new Thread(new ReaderMethod()));
}
public static void main(String[] args) throws InterruptedException {
MyInfinityThread t1 = new MyInfinityThread();
MyInterruptedExceptionThread t2 = new MyInterruptedExceptionThread();
MyHoorayThread t3 = new MyHoorayThread();
StopIfWarning t4 = new StopIfWarning();
ReaderMethod t5 = new ReaderMethod();
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
Thread.sleep(500);
t1.interrupt();
t3.interrupt();
t4.showWarning();
threads.stream()
.forEach(System.out::println);
}
}