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"); }
public void deliver(Plate p) throws InterruptedException { // Only blocks if customer is still // eating the previous course: placeSetting.put(p); }