4 3 2 1 Марш! подскажите, почему так выводит?
package com.javarush.task.task16.task1617;
/*
Отсчет на гонках
*/
import java.util.concurrent.TimeUnit;
public class Solution {
public static volatile int numSeconds = 4;
public static void main(String[] args) throws InterruptedException {
RacingClock clock = new RacingClock();
Thread.sleep(3500);
clock.interrupt();
if (Thread.currentThread().isInterrupted()) {
System.out.println("Прервано!");
} else {
System.out.println("Марш!");
}
}
public static class RacingClock extends Thread {
public RacingClock() {
start();
}
public void run() {
while (numSeconds > 0) {
try {
System.out.print(numSeconds + " ");
numSeconds--;
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}