le Client utilise un sméaphore pour cuir son plat

This commit is contained in:
trochas
2024-12-08 13:29:10 +01:00
parent d414136443
commit 1a0c808353
5 changed files with 21 additions and 94 deletions

View File

@@ -1,30 +1,11 @@
import java.util.LinkedList;
import java.util.Queue;
public class Stand_de_cuisson {
private Queue<Client> clients = new LinkedList<Client>();
private Cuisinier cuisinier;
//get le client en tête de queue
public synchronized Client getClient(){
return clients.peek();
Stand_de_cuisson(Cuisinier cuisinier){
this.cuisinier = cuisinier;
}
//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);
public synchronized void faire_cuire_plat(Client client){
this.cuisinier.faire_cuire(client);
}
}