correction client

This commit is contained in:
trochas
2024-12-03 16:31:37 +01:00
parent da7acb79c4
commit ce6a25f578
3 changed files with 6 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
public class Au_Woke { public class Au_Woke {
private Client[] clients= new Client[30]; private Client[] clients= new Client[100];
private Restaurant restaurant =new Restaurant(); private Restaurant restaurant =new Restaurant();
Au_Woke(){ Au_Woke(){
restaurant.cuisinier.start(); restaurant.cuisinier.start();

View File

@@ -33,7 +33,7 @@ public class Client extends Thread {
} catch (InterruptedException e){ } catch (InterruptedException e){
e.printStackTrace(); e.printStackTrace();
} }
System.out.println("Clien " + Thread.currentThread().getId() + " : a pris une portion de " + compartiment.getName()); System.out.println("Client " + Thread.currentThread().getId() + " : a pris une portion de " + compartiment.getName());
compartiment.servir(r); compartiment.servir(r);
try{ try{
@@ -63,7 +63,7 @@ public class Client extends Thread {
public void manger(){ public void manger(){
try{ try{
System.out.println("Clien " + Thread.currentThread().getId() + " : mange"); System.out.println("Client " + Thread.currentThread().getId() + " : mange");
long temps_manger =new Random().nextInt(2000 - 1000) + 1000; long temps_manger =new Random().nextInt(2000 - 1000) + 1000;
Thread.sleep(temps_manger); Thread.sleep(temps_manger);
}catch(InterruptedException e){ }catch(InterruptedException e){
@@ -73,7 +73,7 @@ public class Client extends Thread {
public void sort(){ public void sort(){
synchronized(restaurant){ synchronized(restaurant){
System.out.println("Clien " + Thread.currentThread().getId() + " : sortir"); System.out.println("Client " + Thread.currentThread().getId() + " : sortir");
restaurant.diminuerClient(); restaurant.diminuerClient();
restaurant.notifyAll(); restaurant.notifyAll();
} }
@@ -86,7 +86,7 @@ public class Client extends Thread {
while (stand.attendClient()!= this) { //Verify s'il est meme client while (stand.attendClient()!= this) { //Verify s'il est meme client
wait(); wait();
} }
System.out.println("Clien " + Thread.currentThread().getId() + " : fait cuir son plat"); System.out.println("Client " + Thread.currentThread().getId() + " : fait cuir son plat");
stand.finir_cuit(this); stand.finir_cuit(this);
}catch (InterruptedException e){ }catch (InterruptedException e){
e.printStackTrace(); e.printStackTrace();

View File

@@ -1,5 +1,5 @@
public class Restaurant { public class Restaurant {
protected final int MAX_CLIENTS = 4; protected final int MAX_CLIENTS = 20;
public int nbClient; public int nbClient;