client update
This commit is contained in:
@@ -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(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user