The verifier says I have an infinite loop.
Not sure why.
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 Thread1());
threads.add(new Thread2());
threads.add(new Thread3());
threads.add(new Thread4());
threads.add(new Thread5());
}
public static class Thread1 extends Thread{
public void run() {
while (true);
}
}
public static class Thread2 extends Thread{
public void run() {
while(! interrupted());
System.out.println("InterruptedException");
}
}
public static class Thread3 extends Thread{
public void run() {
while (true) {
System.out.println("Hurray");
try {
Thread.sleep(500);
} catch (InterruptedException e){}
}
}
}
public static class Thread4 extends Thread implements Message {
public void run() {
while (! interrupted());
}
public void showWarning(){
interrupt();
}
}
public static class Thread5 extends Thread {
public void run() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String in = reader.readLine();
Integer sum = 0;
String ckst = "N";
while (! in.equals(ckst)) {
Integer num = Integer.parseInt(in);
sum += num;
}
System.out.println(sum);
} catch (IOException e) {}
}
}
public static void main(String[] args) {
}
}