ok
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,10 +0,0 @@
|
||||
|
||||
# bloop and metals
|
||||
.bloop
|
||||
.bsp
|
||||
.metals
|
||||
project/metals.sbt
|
||||
|
||||
# vs code
|
||||
.vscode
|
||||
.idea
|
||||
@@ -29,14 +29,14 @@ public class Client extends Thread {
|
||||
this.wait();
|
||||
}
|
||||
} catch (InterruptedException e){
|
||||
throw new RuntimeException(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
compartiment.servir(r);
|
||||
try{
|
||||
long temps_servir =new Random().nextInt(300 - 200) + 200;
|
||||
Thread.sleep(temps_servir);
|
||||
}catch(InterruptedException e){
|
||||
System.out.println(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
compartiment.notifyAll();
|
||||
}
|
||||
@@ -47,12 +47,12 @@ public class Client extends Thread {
|
||||
try{
|
||||
while(!restaurant.libre()){
|
||||
this.wait();
|
||||
}
|
||||
}
|
||||
restaurant.ajouterClient();
|
||||
restaurant.notifyAll();
|
||||
}catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
restaurant.ajouterClient();
|
||||
restaurant.notifyAll();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,17 +61,28 @@ public class Client extends Thread {
|
||||
long temps_manger =new Random().nextInt(2000 - 1000) + 1000;
|
||||
Thread.sleep(temps_manger);
|
||||
}catch(InterruptedException e){
|
||||
System.out.println(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void sort(){
|
||||
restaurant.diminuerClient();
|
||||
restaurant.notifyAll();
|
||||
synchronized(restaurant){
|
||||
restaurant.diminuerClient();
|
||||
restaurant.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void cuir_au_stand(Stand_de_cuisson stand){
|
||||
stand.ajouter_client(this);
|
||||
//TODO
|
||||
synchronized(stand){
|
||||
stand.ajouter_client(this);
|
||||
try{
|
||||
while (stand.attendClient()!= this) { //Verify s'il est meme client
|
||||
wait();
|
||||
}
|
||||
stand.finir_cuit(this);
|
||||
}catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Cuisinier extends Thread {
|
||||
long temps_cuire =new Random().nextInt(300 - 100) + 100;
|
||||
Thread.sleep(temps_cuire);
|
||||
}catch(InterruptedException e){
|
||||
System.out.println(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
stand.finir_cuit(client);
|
||||
stand.notifyAll();
|
||||
|
||||
@@ -7,8 +7,8 @@ public class Stand_de_cuisson {
|
||||
while(clients.isEmpty()){
|
||||
try{
|
||||
wait();
|
||||
}catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return clients.poll();
|
||||
@@ -19,5 +19,6 @@ public class Stand_de_cuisson {
|
||||
|
||||
public synchronized void ajouter_client(Client client){
|
||||
clients.add(client);
|
||||
notify();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user