Не могу пройти валидатор, Time out, выполняется бесконечный цикл , но ведь по условию так и должно быть.
Уже всю голову сломала, открыла верный ответ и не виже чем он принципиально отличается от моего решения.
package com.javarush.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);
public static void main(String[] args) {
}
static {
threads.add(new MyFirstThread());
threads.add(new MySecondThread());
threads.add(new MyThirdThread());
threads.add(new MyFourthThread());
threads.add(new MyFourthThread());
}
public static class MyFirstThread extends Thread {
public void run() {
while (true) {
}
}
}
public static class MySecondThread extends Thread {
public void run() {
try {
Thread.sleep(0);
} catch (InterruptedException e) {
System.out.println("InterruptedException");
}
}
}
public static class MyThirdThread extends Thread {
public void run() {
while (true) {
try {
System.out.println("Ура");
Thread.sleep(500);
} catch (InterruptedException e) {
}
}
}
}
public static class MyFourthThread extends Thread implements Message {
@Override
public void showWarning() {
this.interrupt();
}
public void run() {
while (!isInterrupted()) {
}
}
}
public static class MyFifthThread extends Thread {
int sum;
public void run() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
try {
if (reader.readLine().equals("N")) {
System.out.println(sum);
break;
} else sum = Integer.parseInt(reader.readLine());
sum +=sum;
} catch (IOException e) {
}
}
}
}
}