correction Employe du buffet + Stand de cuisson refait avec un notify et wait
This commit is contained in:
@@ -1,25 +1,34 @@
|
||||
public class Employe_du_buffet extends Thread{
|
||||
|
||||
public Compartiment[] buffet;
|
||||
public Buffet buffet;
|
||||
|
||||
public Employe_du_buffet(Compartiment[] buffet){
|
||||
public Employe_du_buffet(Buffet buffet){
|
||||
this.buffet = buffet;
|
||||
this.setDaemon(true);
|
||||
}
|
||||
|
||||
public void run(){
|
||||
while(Thread.currentThread().isDaemon()){
|
||||
for(int i = 0; i<buffet.length;i++){
|
||||
if(buffet[i].getQuantite()<100){
|
||||
try {
|
||||
while(!buffet[i].isLibre()){
|
||||
buffet[i].wait();
|
||||
synchronized(buffet){
|
||||
while(Thread.currentThread().isDaemon()){
|
||||
for(int i = 0; i<buffet.length();i++){
|
||||
Compartiment compartiment = buffet.getCompartiment(i);
|
||||
|
||||
if(compartiment.getQuantite()<100){
|
||||
try {
|
||||
while(!compartiment.isLibre()){
|
||||
compartiment.wait();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Employe Buffer : remplie de stand " + compartiment.getName() + ", il ne restait plus que " + compartiment.getQuantite() +" g");
|
||||
compartiment.remplir();
|
||||
}
|
||||
System.out.println("Employe Buffer : remplie de stand " + buffet[i].getName() + ", il ne restait plus que " + buffet[i].getQuantite() +" g");
|
||||
buffet[i].remplir();
|
||||
}
|
||||
try {
|
||||
buffet.wait();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user