I checked out all previous problem with verifying this task of course and came to the conclusion that this is one of THOSE tasks
package com.codegym.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 {
threads.add(new Thread(new InfinityThread()));
threads.add(new Thread(new InteruptedThread()));
threads.add(new Thread(new SleepingThread()));
threads.add(new Thread(new FourthThread()));
threads.add(new Thread(new SumThread()));
}
public static void main(String[] args) {
}
public static class InfinityThread implements Runnable {
public void run() {
while (true) {
}
}
}
public static class InteruptedThread implements Runnable {
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println("InterruptedException");
}
}
}
public static class SleepingThread implements Runnable {
public void run() {
try {
while (!Thread.interrupted()) {
System.out.println("Hurray");
Thread.sleep(500);
}
} catch (InterruptedException e) {
}
}
}
public static class FourthThread extends Thread implements Message {
public void run() {
while(isAlive()){
showWarning();
}
}
public void showWarning() {
this.interrupt();
}
}
public static class SumThread implements Runnable {
public void run() {
try {
int n = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String s = br.readLine();
if (s.equals("N"))
break;
n += Integer.parseInt(s);
}
System.out.println(n);
} catch (IOException e) {
}
}
}
}