а как валидатор принял решение без создания объекта? или потому , что тут 1 нить? как лучше писать?
p
ublic 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 {
//без Thread current = Thread.currentThread();
while (!isInterrupted()) { //и без !current.isInterrupted() решение засчиталось
Thread.sleep(1000);
seconds++;
}
} catch (InterruptedException e) {
System.out.println(seconds);
}
}
}
}