public void run(){ // Service
int numChicks = 0;
int index;
boolean ready[] = new boolean[2];
Alternative alt = new Alternative(in);
ready[0] = true;
while(true){
ready[1] = (numChicks > 0);
index = alt.select(ready);
if(index == 0){
numChicks = in[0].read();
nap(3000);
in[0].read();
}
else{
in[1].read();
numChicks--;
toServer.write(1);
} } } }
Previous slide | Next slide | Back to first slide | View graphic version |