Код отрабатывает корректно вроде...
package com.javarush.task.task16.task1617;
/*
Отсчет на гонках
*/
public class Solution {
public static volatile int numSeconds = 4;
public static void main(String[] args) throws InterruptedException {
RacingClock clock = new RacingClock();
//add your code here - добавь код тут
try {
Thread.sleep(3500);
} catch (InterruptedException e) {
clock.interrupt();
}
clock.interrupt();
}
public static class RacingClock extends Thread {
public RacingClock() {
start();
}
public void run() {
//add your code here - добавь код тут
if (numSeconds <= 3) {
while (numSeconds != 0) {
try {
Thread.sleep(1000);
System.out.print(numSeconds + " ");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
numSeconds--;
}
System.out.println("Марш!");
} else if (numSeconds > 3) {
while (numSeconds != 0) {
try {
Thread.sleep(1000);
System.out.print(numSeconds + " ");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
numSeconds--;
}
System.out.println("Прервано!");
}
// for (int i = numSeconds; i > 0; i--) {
// try {
// Thread.sleep(1000);
// System.out.print(i + " ");
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// }
// System.out.println("Марш!");
//this.interrupt();
}
}
}