Hello Someone can help me
Thanks
package fr.codegym.task.task16.task1626;
public class Solution {
public static int number = 5;
public static void main(String[] args) {
new Thread(new CountdownRunnable(), "Réduction").start();
new Thread(new CountUpRunnable(), "Augmentation").start();
}
public static class CountUpRunnable implements Runnable {
private int countdownIndex = 0;
@Override
public void run() {
try{
System.out.println(toString());
Thread.sleep(2500);
} catch(InterruptedException ie) {
ie.printStackTrace();
}
}
//écris ton code ici
public String toString() {
return Thread.currentThread().getName() + ": " + countdownIndex;
}
}
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;
}
}
}