| Lecture 14 - slide 35 : 41 Program 2 |
class Consumer extends Thread {
private CubbyHole cubbyhole;
private int number;
public Consumer(CubbyHole c, int number) {
cubbyhole = c;
this.number = number;
}
public void run() {
int value = 0;
for (int i = 0; i < 10; i++) {
value = cubbyhole.get();
try {
sleep((int)(Math.random() * 100));
} catch (InterruptedException e) { }
}
}
} // end Consumer |