Thread'ы есть в списке, вроде работают корректно, но валидатор заворачиват, что не так?
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.IllegalFormatException;
import java.util.List;
public class Solution {
public static List<Thread> threads = new ArrayList<>(5);
public static void main(String[] args) {
Runnable thr1 = ()->{while (true){
try {
Thread.sleep(10);
}catch (InterruptedException ie){
ie.getMessage();
}
}};
Thread thread1 = new Thread(thr1,"thread 1");
threads.add(thread1);
Runnable thr2 = ()->{
try{throw new InterruptedException();}catch (InterruptedException ie){
System.out.println("InterruptedException");
}
};
Thread thread2 = new Thread(thr2,"thread 2");
threads.add(thread2);
Runnable thr3 = ()->{
try{while (true) {
Thread.sleep(500);
System.out.println("Ура");
}
}catch (InterruptedException ie){
System.out.println("InterruptedException");
}
};
Thread thread3 = new Thread(thr3,"thread 3");
threads.add(thread3);
Runnable thr4 = new Tread4();
Thread thread4 = new Thread(thr4,"thread 4");
threads.add(thread4);
Runnable thr5 = ()->{
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
int result = 0;
try{
while (true) {
try{
int i = Integer.parseInt(buff.readLine());
result += i;
}catch (NumberFormatException nfe){
System.out.println(result);
break;
}
}
}catch (IOException io){}
};
Thread thread5 = new Thread(thr5, "thread 5");
threads.add(thread5);
for (Thread t: threads){
System.out.println(t.getName());
}
for (int i = 0; i < threads.size(); i++){
threads.get(i).start();
}
}
public static class Tread4 implements Message, Runnable{
@Override
public void run() {
showWarning();
}
@Override
public void showWarning(){
Thread thread = Thread.currentThread();
thread.interrupt();
}
}
}