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
int seconds = numSeconds;
while(numSeconds >= 1) {
try {
System.out.print ( numSeconds );
Thread.sleep ( 1000 );
if (numSeconds == 1 & seconds == 3) {
System.out.println ( " Go!" );
break;
}
--numSeconds;
} catch (InterruptedException e) {
System.out.print ( " interrupted!" );
break;
}
}
}
}
}
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
int seconds = numSeconds;
while(numSeconds >= 1) {
try{
System.out.print ( numSeconds );
Thread.sleep ( 1000 );
if (numSeconds == 1 & seconds == 3 ) {
System.out.println ( " Go!" );
break;
}
--numSeconds;
}catch (InterruptedException e){
System.out.print ( " interrupted!" );
break;
}
}
}
}
}