thread 4 requirement doesn't validate
package com.codegym.task.task16.task1632;
import javax.swing.plaf.TableHeaderUI;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import static java.lang.Thread.currentThread;
import static java.lang.Thread.interrupted;
public class Solution {
public static List<Thread> threads = new ArrayList<>(5);
static
{
threads.add(new Thread(new InfiniteThread()));
threads.add(new Thread(new InterruptedThread()));
threads.add(new Thread(new HurrayThread()));
threads.add(new Thread(new MessageThread()));
threads.add(new Thread(new SumThread()));
}
public static void main(String[] args) {
}
public static class InfiniteThread implements Runnable
{
@Override
public void run() {
while(true){}
}
}
public static class InterruptedThread implements Runnable{
public void run()
{
try{
throw new InterruptedException();
}catch(InterruptedException e){
System.out.println("InterruptedException");
}}
}
public static class HurrayThread implements Runnable{
public void run()
{
try {
while (true){
System.out.println("Hurray");
Thread.sleep(500);
}
}catch (InterruptedException e){}
}
}
public static class MessageThread extends Thread implements Message{
@Override
public void run() {
while(isAlive()){
}
}
@Override
public void showWarning() {
this.interrupt();
}
}
public static class SumThread implements Runnable{
@Override
public void run() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try{
int sum =0;
String s;
while(true) {
s = reader.readLine();
if (s.equals("N"))
break;
sum += Integer.parseInt(s);
}
System.out.println(sum);
}catch(Exception e){}
}
}
}