Last condition not verified. Don't know why.
Neither do I know why the validator is complaining about too much data on screen....
package com.codegym.task.task16.task1626;
import javax.security.sasl.SaslServer;
public class Solution {
public static int number = 5;
public static void main(String[] args) {
new Thread(new CountdownRunnable(), "Decrease").start();
new Thread(new CountUpRunnable(), "Increase").start();
}
public static class CountUpRunnable implements Runnable {
//write your code here
private int countupIndex = 1;
@Override
public void run() {
long startTime = System.currentTimeMillis();
try {
while ((System.currentTimeMillis() - startTime < 2500)
|| countupIndex < Solution.number) {
System.out.println(toString());
countupIndex += 1;
Thread.sleep(500);
}
} catch (InterruptedException e) {
}
}
@Override
public String toString() {
return Thread.currentThread().getName() + ": " + countupIndex;
}
}
public static class CountdownRunnable implements Runnable {
private int countdownIndex = Solution.number;
public void run() {
try {
while (true) {
System.out.println(toString());
countdownIndex -= 1;
if (countdownIndex == 0) return;
Thread.sleep(500);
}
} catch (InterruptedException e) {
}
}
public String toString() {
return Thread.currentThread().getName() + ": " + countdownIndex;
}
}
}