Why?? whats wrong??
@#$@#@#
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 implements Message {
public static List<Thread> threads = new ArrayList<>(5);
@Override
public void showWarning() {
threads.get(3).stop();
}
static {
Thread t1 = new Thread(){
@Override
public void run() {
while (true) {
}
}
};
Thread t2 = new Thread(){
@Override
public void run() {
if (Thread.interrupted())
try {
throw new InterruptedException();
} catch (InterruptedException e) {
System.out.println("InterruptedException");
}
}
};
Thread t3 = new Thread(){
@Override
public void run() {
try {
while (true) {
System.out.println("Hurray");
Thread.sleep(500);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
class T4 extends Thread implements Message {
@Override
public void showWarning() {
this.stop();
}
@Override
public void run() {
while (isAlive()) {
}
}
}
Thread t4 = new T4();
Thread t5 = new Thread() {
@Override
public void run() {
int sum = 0;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
while(!reader.ready()) {
String s = reader.readLine();
if (s.equals("N")) break;
sum = sum + Integer.parseInt(s);
}
reader.close();
System.out.println(sum);
}
catch (IOException e){
e.printStackTrace();
}
}
};
threads.add(t1);
threads.add(t2);
threads.add(t3);
threads.add(t4);
threads.add(t5);
}
public static void main(String[] args) throws InterruptedException {
}
}