Второй день бьюсь, не пойму что не так
package com.javarush.task.task16.task1632;
import javax.crypto.spec.PSource;
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);
public static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
static {
threads.add(new ThreadSon1());
threads.add(new ThreadSon2());
threads.add(new ThreadSon3());
threads.add(new ThreadSon4());
threads.add(new ThreadSon5());
}
public static void main(String[] args) throws InterruptedException {
}
public static class ThreadSon1 extends Thread {
@Override
public void run() {
while (true) {
}
}
}
public static class ThreadSon2 extends Thread {
@Override
public void run() {
while (true) {
if (Thread.interrupted()) // Clears interrupted status!
try {
throw new InterruptedException();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public static class ThreadSon3 extends Thread {
@Override
public void run() {
while (!isInterrupted()) {
System.out.println("Ура");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
System.out.println("Не ура");
return;
}
}
}
}
public static class ThreadSon4 extends Thread implements Message {
private boolean switchOff;
@Override
public void run() {
while (!switchOff) {
System.out.println("работает №4");
}
System.out.println("конец №4");
}
@Override
public void showWarning() {
switchOff = true;
}
}
public static class ThreadSon5 extends Thread {
@Override
public void run() {
int num = 0;
String s = "";
try {
while ((s = reader.readLine()) != "N") {
num += Integer.parseInt(s);
}
} catch (IOException e) {
System.out.println("Ups #5");
} catch (NumberFormatException e) {
}
System.out.println(num);
}
}
}