Какой - то бред. Если я countSeconds поставлю 4 то не проходит 5 пункт, ставлю 3 не проходит 6 , но выводит все верно при этом и при 3 и при 4. Странно как - то) Видимо я туплю
package com.javarush.task.task16.task1617;
/*
Отсчет на гонках
*/
public class Solution {
public static volatile int countSeconds = 4;
public static int countSecond2 = countSeconds;
public static void main(String[] args) throws InterruptedException {
RacingClock clock = new RacingClock();
Thread.sleep(3500);
clock.interrupt();
if (countSecond2 > 3){
System.out.println("Прервано!");
}
}
public static class RacingClock extends Thread {
public RacingClock() {
start();
}
public void run() {
try{
while(!currentThread().isInterrupted()){
if (countSeconds == 0){
System.out.println("Марш!");
}
else System.out.print(countSeconds + " ");
Thread.sleep(1000);
countSeconds--;
}
}
catch(InterruptedException e){
}
}
}
}