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