client update

This commit is contained in:
Minh VU
2024-11-28 09:40:01 +01:00
parent bc9aa8d7e6
commit f64b346749

View File

@@ -1,3 +1,31 @@
import java.util.Random;
public class Client extends Thread {
private int MAX_PORTION = 100;
protected Compartiment compartiment;
public Client (Compartiment c){
this.compartiment=c;
}
public void prendre_portion(Compartiment compartiment){
synchronized(compartiment){
int r =new Random().nextInt(MAX_PORTION);
try{
while(r > compartiment.getQuantite()){
this.wait();
}
} catch (InterruptedException e){
throw new RuntimeException(e);
}
compartiment.servir(r);
int temps_servir =new Random().nextInt(300 - 200) + 200;
//this.wait(temps_servir);
compartiment.notifyAll();
}
}
public void entrer(){
}
}