I know there's a bug in my logic, I just can't figure it out. Thanks.
package com.codegym.task.task16.task1617;
/*
Countdown at the races
*/
public class Solution {
public static volatile int numSeconds = 4;
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
boolean isCurrent = false;
while(!isCurrent) {
try {
System.out.print(numSeconds + " ");
numSeconds--;
Thread.sleep(1000);
if(numSeconds == 0) {
System.out.print("Go!");
isCurrent = true;
break;
}
if(isCurrent) {
System.out.print("Interrupted");
break;
}
}
catch (InterruptedException e){}
}
}
}
}