Guarded Communication in Java
Guarded Communication in Java
public void run() {
Select sel = new Select();
sel.add(leave);
sel.add(arrive);
while(true) {
for(int i=0;i<15;i++) DisplayThread.rotate();
leave.guard(count.value()>0);
arrive.guard(count.value()
switch (sel.choose()) {
case 1:leave.in();
count.dec();
break;
case 2:arrive.in();
count.inc();
break;
}
}
}
Demo
Previous slide
Next slide
Back to the first slide
View Graphic Version