I don't a get question i guess, because numSeconds never will be equals to 4.
Please, help me to find solution for this task and tell me why it's not valid answer.
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() {
try {
while(numSeconds>0)
{ Thread.sleep(1000);
if(numSeconds == 3){
System.out.println("3 2 1 Go!");
}else if(numSeconds == 4){
System.out.println("4 3 2 1 Interrupted!");
}
numSeconds--;}
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
}