ok
This commit is contained in:
@@ -52,7 +52,7 @@ public class Client extends Thread {
|
||||
while(!restaurant.libre()){
|
||||
restaurant.wait();
|
||||
}
|
||||
System.out.println("Clien " + Thread.currentThread().getId() + " : est entré dans le restaurant");
|
||||
System.out.println("Client " + Thread.currentThread().getId() + " : est entré dans le restaurant");
|
||||
restaurant.ajouterClient();
|
||||
restaurant.notifyAll();
|
||||
}catch (InterruptedException e) {
|
||||
|
||||
@@ -9,7 +9,8 @@ public class Cuisinier extends Thread {
|
||||
}
|
||||
|
||||
public void run(){
|
||||
while(Thread.currentThread().isDaemon()){
|
||||
while(Thread.currentThread().isDaemon()){
|
||||
//while(true){
|
||||
Client client= stand.attendClient();
|
||||
if(client!= null){
|
||||
faire_cuire(client);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
public class Restaurant {
|
||||
protected final int MAX_CLIENTS = 25;
|
||||
protected final int MAX_CLIENTS = 4;
|
||||
|
||||
public int nbClient;
|
||||
|
||||
@@ -41,11 +41,7 @@ public class Restaurant {
|
||||
|
||||
}
|
||||
public synchronized boolean libre(){
|
||||
if(nbClient>MAX_CLIENTS){
|
||||
return false;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
return (MAX_CLIENTS>nbClient);
|
||||
}
|
||||
public synchronized void ajouterClient(){
|
||||
if(nbClient<MAX_CLIENTS){
|
||||
@@ -54,9 +50,7 @@ public class Restaurant {
|
||||
}
|
||||
|
||||
public synchronized void diminuerClient(){
|
||||
if(nbClient>MAX_CLIENTS){
|
||||
nbClient--;
|
||||
}
|
||||
nbClient--;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user