Daemon
This commit is contained in:
@@ -31,6 +31,8 @@ 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");
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ public class Cuisinier extends Thread {
|
|||||||
|
|
||||||
public Cuisinier(Stand_de_cuisson stand_de_cuisson){
|
public Cuisinier(Stand_de_cuisson stand_de_cuisson){
|
||||||
this.stand= stand_de_cuisson;
|
this.stand= stand_de_cuisson;
|
||||||
|
this.setDaemon(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
while(true){
|
while(Thread.currentThread().isDaemon()){
|
||||||
Client client= stand.attendClient();
|
Client client= stand.attendClient();
|
||||||
if(client!= null){
|
if(client!= null){
|
||||||
faire_cuire(client);
|
faire_cuire(client);
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ public class Employe_du_buffet extends Thread{
|
|||||||
|
|
||||||
public Compartiment[] buffet;
|
public Compartiment[] buffet;
|
||||||
|
|
||||||
Employe_du_buffet(Compartiment[] buffet){
|
public Employe_du_buffet(Compartiment[] buffet){
|
||||||
this.buffet = buffet;
|
this.buffet = buffet;
|
||||||
|
this.setDaemon(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
while(true){
|
while(Thread.currentThread().isDaemon()){
|
||||||
for(int i = 0; i<buffet.length;i++){
|
for(int i = 0; i<buffet.length;i++){
|
||||||
if(buffet[i].getQuantite()<100){
|
if(buffet[i].getQuantite()<100){
|
||||||
System.out.println("Employe Buffer : remplie de stand " + i);
|
System.out.println("Employe Buffer : remplie de stand " + i);
|
||||||
|
|||||||
Reference in New Issue
Block a user