Everything is working with 4 and with 3.
But Validator doesn't want to accepting it...
is anything wrong with that?
Any explanation will help..
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
if(numSeconds<3.5) {
for (int i = numSeconds; i > 0; i--) {
System.out.print(numSeconds + " ");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
numSeconds--;
if(i==1)
{
System.out.print("GO!");
}
}
}
else {
for (int i = numSeconds; i > 0; i--) {
System.out.print(numSeconds + " ");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
numSeconds--;
if(i==1)
{
System.out.print("Interrupted!");
Thread.currentThread().interrupt();
}
}
}
}
}
}
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
if(numSeconds<3.5) {
for (int i = numSeconds; i > 0; i--) {
System.out.print(numSeconds + " ");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
numSeconds--;
if(i==1)
{
System.out.print("GO!");
}
}
}
else {
for (int i = numSeconds; i > 0; i--) {
System.out.print(numSeconds + " ");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
numSeconds--;
if(i==1)
{
System.out.print("Interrupted!");
Thread.currentThread().interrupt();
}
}
}
}
}
}