diff --git a/src/Client.java b/src/Client.java index ec4154c..fc6f745 100644 --- a/src/Client.java +++ b/src/Client.java @@ -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(){ + + } }