ok
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
# bloop and metals
|
|
||||||
.bloop
|
|
||||||
.bsp
|
|
||||||
.metals
|
|
||||||
project/metals.sbt
|
|
||||||
|
|
||||||
# vs code
|
|
||||||
.vscode
|
|
||||||
.idea
|
|
||||||
@@ -29,14 +29,14 @@ public class Client extends Thread {
|
|||||||
this.wait();
|
this.wait();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e){
|
} catch (InterruptedException e){
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
compartiment.servir(r);
|
compartiment.servir(r);
|
||||||
try{
|
try{
|
||||||
long temps_servir =new Random().nextInt(300 - 200) + 200;
|
long temps_servir =new Random().nextInt(300 - 200) + 200;
|
||||||
Thread.sleep(temps_servir);
|
Thread.sleep(temps_servir);
|
||||||
}catch(InterruptedException e){
|
}catch(InterruptedException e){
|
||||||
System.out.println(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
compartiment.notifyAll();
|
compartiment.notifyAll();
|
||||||
}
|
}
|
||||||
@@ -47,12 +47,12 @@ public class Client extends Thread {
|
|||||||
try{
|
try{
|
||||||
while(!restaurant.libre()){
|
while(!restaurant.libre()){
|
||||||
this.wait();
|
this.wait();
|
||||||
}
|
}
|
||||||
|
restaurant.ajouterClient();
|
||||||
|
restaurant.notifyAll();
|
||||||
}catch (InterruptedException e) {
|
}catch (InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
restaurant.ajouterClient();
|
|
||||||
restaurant.notifyAll();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,17 +61,28 @@ public class Client extends Thread {
|
|||||||
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){
|
||||||
System.out.println(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sort(){
|
public void sort(){
|
||||||
restaurant.diminuerClient();
|
synchronized(restaurant){
|
||||||
restaurant.notifyAll();
|
restaurant.diminuerClient();
|
||||||
|
restaurant.notifyAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cuir_au_stand(Stand_de_cuisson stand){
|
public void cuir_au_stand(Stand_de_cuisson stand){
|
||||||
stand.ajouter_client(this);
|
synchronized(stand){
|
||||||
//TODO
|
stand.ajouter_client(this);
|
||||||
|
try{
|
||||||
|
while (stand.attendClient()!= this) { //Verify s'il est meme client
|
||||||
|
wait();
|
||||||
|
}
|
||||||
|
stand.finir_cuit(this);
|
||||||
|
}catch (InterruptedException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class Cuisinier extends Thread {
|
|||||||
long temps_cuire =new Random().nextInt(300 - 100) + 100;
|
long temps_cuire =new Random().nextInt(300 - 100) + 100;
|
||||||
Thread.sleep(temps_cuire);
|
Thread.sleep(temps_cuire);
|
||||||
}catch(InterruptedException e){
|
}catch(InterruptedException e){
|
||||||
System.out.println(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
stand.finir_cuit(client);
|
stand.finir_cuit(client);
|
||||||
stand.notifyAll();
|
stand.notifyAll();
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ public class Stand_de_cuisson {
|
|||||||
while(clients.isEmpty()){
|
while(clients.isEmpty()){
|
||||||
try{
|
try{
|
||||||
wait();
|
wait();
|
||||||
}catch (Exception e) {
|
}catch (InterruptedException e) {
|
||||||
System.out.println(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return clients.poll();
|
return clients.poll();
|
||||||
@@ -19,5 +19,6 @@ public class Stand_de_cuisson {
|
|||||||
|
|
||||||
public synchronized void ajouter_client(Client client){
|
public synchronized void ajouter_client(Client client){
|
||||||
clients.add(client);
|
clients.add(client);
|
||||||
|
notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user