import java.util.Random; class BoiteAuxLettres { private boolean plein = false; private String lettre; synchronized void deposer(String lettre) { try { while (plein) { wait(); System.out.println(lettre+" reveille"); } } catch(InterruptedException exc) {} this.lettre = lettre; System.out.println("depot de : " + lettre); plein = true; notifyAll(); } synchronized String retirer(String nomConso) { try { while (!plein) { wait(); } } catch(InterruptedException exc) { return null; } System.out.println(nomConso + " lit : " + lettre); plein = false; notifyAll(); return lettre; } } class Producteur extends Thread { BoiteAuxLettres boite; String nom; Random alea; Producteur(BoiteAuxLettres boite, String nom, Random alea) { this.boite = boite; this.nom = nom; this.alea = alea; } public void run() { for (int i=0;i