Validation failing for race clock countdown by 1. cannot see where the problem is.
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();
//write your code here
Thread.sleep(3500);
clock.interrupt();
}
public static class RacingClock extends Thread {
public RacingClock() {
start();
}
public void run() {
//write your code here
try{
boolean isThree = false;
while (numSeconds <= 4 && numSeconds >= 1){
if (numSeconds == 3)
{
isThree = true;
}
System.out.print(numSeconds + " ");
Thread.sleep(1000);
numSeconds = numSeconds - 1;
}
if (isThree){
System.out.print("Go!");
}
}
catch (InterruptedException e) {
System.out.print("Interrupted!");
}
}
}
}