public static void main(String[] args) throws IOException {
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(in);
Stopwatch stopwatch = new Stopwatch();
stopwatch.start();
reader.readLine();
stopwatch.interrupt();
reader.close();
in.close();
}
Правильно ли я понял, что isInterrupted() проверяет был ли данный поток остановлен?
public void run() {
try {
while(!Thread.currentThread().isInterrupted()) {
Thread.sleep(1000);
seconds++;
}
} catch (InterruptedException e) {
System.out.println(seconds);
}
}
Тогда почему после:
stopwatch.interrupt();
Не выкинуло исключение?