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