Merge branch 'master' of https://codefirst.iut.uca.fr/git/elliott.le_guehennec/Eclair
commit
8603c04e28
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
import sweet.*;
|
||||
import world.ThreadWeaver;
|
||||
|
||||
public class Main3A {
|
||||
public static void main(String[] args) {
|
||||
ThreadWeaver tw = new ThreadWeaver();
|
||||
Boulangerie b = new BoulangerieThreadSafe();
|
||||
Patissier p = new Patissier(b);
|
||||
tw.addRunners(p, new LimitedClient(b));
|
||||
tw.weave();
|
||||
tw.run();
|
||||
|
||||
try{
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
p.shouldRun.set(false);
|
||||
tw.recover();
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
import sweet.*;
|
||||
import world.ThreadWeaver;
|
||||
|
||||
public class Main3B {
|
||||
public static void main(String[] args) {
|
||||
ThreadWeaver tw = new ThreadWeaver();
|
||||
Boulangerie b = new BoulangerieThreadSafe();
|
||||
Patissier p = new Patissier(b);
|
||||
tw.addRunners(p, new Client(b));
|
||||
tw.weave();
|
||||
tw.run();
|
||||
|
||||
try{
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
p.shouldRun.set(false);
|
||||
tw.recover();
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package sweet;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PatissierSuicidal extends Patissier {
|
||||
public AtomicBoolean shouldRun = new AtomicBoolean(true);
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public PatissierSuicidal(Boulangerie b) {
|
||||
super(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while(shouldRun.get()) {
|
||||
if(!local.depose(new Patisserie())){
|
||||
shouldRun.set(false);
|
||||
}
|
||||
System.out.println("J'ai produit ma patisserie");
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue