The task verification request was not completed correctly. Be sure you have a network connection and try again.
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 {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Thread thread = new Thread("1") {
@Override
public void run() {
while (true) {}
}
};
threads.add(thread);
//thread.start();
Thread thread1 = new Thread("2") {
@Override
public void run() {
try {
throw new InterruptedException();
} catch (InterruptedException e) {
System.out.println("InterruptedException");
}
}
};
threads.add(thread1);
//thread1.start();
Thread thread2 = new Thread("3") {
@Override
public void run() {
try {
while (true) {
Thread.sleep(500);
System.out.println("Hurray");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
threads.add(thread2);
//thread2.start();
Mess mess = new Mess ();
threads.add(mess);
//thread3.start();
Thread thread4 = new Thread("5") {
@Override
public void run() {
//String s = "N";
String ss = "";
int sum = 0;
while (true) {
try {
ss = reader.readLine();
if ("N".equals(ss)) break;
sum += Integer.parseInt(ss);
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println(sum);
}
};
threads.add(thread4);
}
public static void main(String[] args) {
}
public static class Mess extends Thread implements Message{
@Override
public void showWarning() {
if (isAlive()) {
Thread.currentThread().stop();
}
}
@Override
public void run() {
}
}
}