Второй день бьюсь, не проходит валидатор, говорит что "После прерывания работы нити Stopwatch (вызова метода interrupt), метод run должен вывести количество секунд (seconds) в консоль." Хотя все выводит вроде норм. В чем может быть косяк?
public class Solution {
public static void main(String[] args) throws IOException {
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(in);
//create and run thread
Stopwatch stopwatch = new Stopwatch();
stopwatch.start();
//read a string
reader.readLine();
stopwatch.interrupt();
//close streams
reader.close();
in.close();
}
public static class Stopwatch extends Thread {
private int seconds;
public void run() {
try {
while (!isInterrupted()) {
seconds++;
System.out.println(seconds);
Thread.sleep(1000);
}
} catch (InterruptedException e) {
System.out.println(seconds);
}
}
}
}