Почему непроходит по 3 и 4?
package com.javarush.task.task16.task1626;
public class Solution {
public static int number = 5;
public static void main(String[] args) {
new Thread(new CountdownRunnable(), "Уменьшаем").start();
new Thread(new CountUpRunnable(), "Увеличиваем").start();
}
public static class CountUpRunnable implements Runnable {
private int count = 1;
public void run() {
try {
while(true) {
if (count == 5)
break;
System.out.println(toString());
count++;
Thread.sleep(500);
}
}
catch (Exception e) {
}
}
public String toString() {
return Thread.currentThread().getName() + " : " + count;
}
}
public static class CountdownRunnable implements Runnable {
private int countIndexDown = Solution.number;
public void run() {
try {
while (true) {
if (countIndexDown == 0)
break;
System.out.println(toString());
countIndexDown -= 1;
Thread.sleep(500);
}
} catch (InterruptedException e) {
}
}
public String toString() {
return Thread.currentThread().getName() + ": " + countIndexDown;
}
}
}