I don't know where is the problem. When I check by Run - the program prints "3 2 1 0 Go!" but during the verification its prints only "3 2 1 0" and i don't know how to solve the problem.
package com.codegym.task.task16.task1617;
/*
Countdown at the races
*/
public class Solution {
public static volatile int numSeconds = 3;
public static void main(String[] args) throws InterruptedException {
RacingClock clock = new RacingClock();
Thread.sleep(3500);
clock.interrupt();
}
public static class RacingClock extends Thread {
public RacingClock() {
start();
}
public void run() {
final int newSeconds = numSeconds;
try {
for (int i = numSeconds; i >= 0; i--) {
System.out.print(numSeconds + " ");
Thread.sleep(1000);
numSeconds--;
}
} catch (InterruptedException e) {
if (newSeconds == 3) {
System.out.print("Go!");
} else
System.out.print("Interrupted!");
}
}
}
}