import java.util.*; public class redormeur implements Runnable { String nom = null; Queue antecedents = new LinkedList(); public redormeur(String nom){ this.nom = nom; } public void SetAntecedent(Queue antecedents){ this.antecedents =new LinkedList(antecedents); } public void run() { System.out.format("%s, started !\n", nom); for (Thread t : antecedents) { try{ t.join(); System.out.format("%s: %s a fini !!\n", nom,t.getName()); } catch (InterruptedException e) { System.out.format("Issue with %s inte while waiting\n", nom);} } System.out.format("%s dit: Super je peux enfin demarrer! !\n", nom); zzzz(); System.out.format("%s dit: Super j'ai FINI!!! !\n", nom); } public static void main(String[] args) throws Exception { redormeur OC = new redormeur("Glandeur C"); Thread TC = new Thread(OC, "Mister C"); redormeur OB = new redormeur("Glandeur B"); Thread TB = new Thread(OB, "Mister B"); redormeur OA = new redormeur("Glandeur A"); Thread TA = new Thread(OA, "Mister A"); Queue file = new LinkedList(); file.add(TB); file.add(TC); OA.SetAntecedent(file); file = new LinkedList(); file.add(TC); OB.SetAntecedent(file); TA.start(); TB.start(); TC.start(); System.out.format("Main :Fini ici !\n"); } private void zzzz(){ try { Thread.sleep((int) (1e3 * Math.random())); } catch (InterruptedException e) { e.printStackTrace(); } } }