Hello Someone can help me
Thanks
package fr.codegym.task.task16.task1622;
/*
Threads consécutifs
*/
public class Solution {
public volatile static int COUNT = 4;
public static void main(String[] args) throws InterruptedException {
for (int i = 0; i < COUNT; i++) {
SleepingThread x = new SleepingThread();
//écris ton code ici
x.join();
if(x.isInterrupted()) {
System.out.println("Thread interrompu");
}
}
}
public static class SleepingThread extends Thread {
private static volatile int threadCount = 0;
private volatile int countdownIndex = COUNT;
public SleepingThread() {
super(String.valueOf(++threadCount));
start();
interrupt();
}
public void run() {
while (true) {
System.out.println(this);
if (--countdownIndex == 0) return;
//écris ton code ici
try{
Thread.sleep(10);
}
catch(InterruptedException ie) {
ie.printStackTrace();
}
}
}
public String toString() {
return "#" + getName() + ": " + countdownIndex;
}
}
}