Revert "le Client utilise un sméaphore pour cuir son plat"

This reverts commit 1a0c808353
This commit is contained in:
Rochas Thibaut
2024-12-08 12:31:32 +00:00
parent 1a0c808353
commit aab11f6869
5 changed files with 95 additions and 22 deletions

View File

@@ -1,11 +1,30 @@
public class Stand_de_cuisson {
private Cuisinier cuisinier;
import java.util.LinkedList;
import java.util.Queue;
Stand_de_cuisson(Cuisinier cuisinier){
this.cuisinier = cuisinier;
public class Stand_de_cuisson {
private Queue<Client> clients = new LinkedList<Client>();
//get le client en tête de queue
public synchronized Client getClient(){
return clients.peek();
}
public synchronized void faire_cuire_plat(Client client){
this.cuisinier.faire_cuire(client);
//supprime le client en tête de queue
public synchronized void nextClient(){
clients.poll();
}
public synchronized void finir_cuit(){
notifyAll();
}
public synchronized void ajouter_client(Client client){
clients.add(client);
notifyAll();
}
public synchronized boolean containsClient(Client client){
return this.clients.contains(client);
}
}