correction du stand de cuissant et cuisinier

This commit is contained in:
Rochas
2024-12-07 12:37:03 +01:00
parent ce6a25f578
commit 3624e1ab66
9 changed files with 90 additions and 19 deletions

View File

@@ -3,7 +3,11 @@ import java.util.Queue;
public class Stand_de_cuisson {
private Queue<Client> clients = new LinkedList<Client>();
public synchronized Client attendClient(){
/*
* retourne le client qui est en tête de queue et le supprime de la queue
*/
public synchronized Client getNextClient2(){
while(clients.isEmpty()){
try{
wait();
@@ -13,6 +17,17 @@ public class Stand_de_cuisson {
}
return clients.poll();
}
//get le client en tête de queue
public synchronized Client getClient(){
return clients.peek();
}
//supprime le client en tête de queue
public synchronized void nextClient(){
clients.poll();
}
public synchronized void finir_cuit(Client client){
notifyAll();
}
@@ -21,4 +36,8 @@ public class Stand_de_cuisson {
clients.add(client);
notify();
}
public synchronized boolean containsClient(Client client){
return this.clients.contains(client);
}
}