This commit is contained in:
Minh VU
2024-12-03 16:28:22 +01:00
parent f47f77dc00
commit da7acb79c4
3 changed files with 6 additions and 11 deletions

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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--;
}
}