Подскажите, пожалуйста
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<>();
static {
FirstThread thread1 = new FirstThread();
SecondThread thread2 = new SecondThread();
ThirdThread thread3 = new ThirdThread();
FourthThread thread4 = new FourthThread();
FifthThread thread5 = new FifthThread();
threads.add(thread1);
threads.add(thread2);
threads.add(thread3);
threads.add(thread4);
threads.add(thread5);
}
public static void main(String[] args) throws InterruptedException {
for (Thread thread : threads) {
thread.start();
}
threads.get(2).interrupt();
Thread.sleep(1000);
threads.get(4).interrupt();
}
public static class FirstThread extends Thread {
@Override
public void run() {
while (true) {
}
}
}
public static class SecondThread extends Thread {
@Override
public void run() {
try {
Thread.sleep(0);
} catch (InterruptedException e) {
System.out.println("InterruptedException");
}
}
}
public static class ThirdThread extends Thread {
@Override
public void run() {
while (!currentThread().isInterrupted()) {
System.out.println("Ура");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public static class FourthThread extends Thread implements Message {
@Override
public void run() {
if(threads.get(3).isAlive())
showWarning();
}
@Override
public void showWarning() {
FourthThread.currentThread().interrupt();
}
}
public static class FifthThread extends Thread {
@Override
public void run() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s;
int a;
int count = 0;
while (!currentThread().isInterrupted()) {
try {
s = reader.readLine();
if (s.equals("N")) {
System.out.println(count);
break;
}
a = Integer.parseInt(s);
count += a;
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}