コード例 #1
0
 public void run() {
   for (Course course : Course.values()) {
     Food food = course.randomSelection();
     try {
       waitPerson.placeOrder(this, food);
       // Blocks until course has been delivered:
       print(this + "eating " + placeSetting.take());
     } catch (InterruptedException e) {
       print(this + "waiting for " + course + " interrupted");
       break;
     }
   }
   print(this + "finished meal, leaving");
 }
コード例 #2
0
 public void deliver(Plate p) throws InterruptedException {
   // Only blocks if customer is still
   // eating the previous course:
   placeSetting.put(p);
 }