public Restaurant(ExecutorService e, int nWaitPersons, int nChefs) {
   exec = e;
   for (int i = 0; i < nWaitPersons; i++) {
     WaitPerson waitPerson = new WaitPerson(this);
     waitPersons.add(waitPerson);
     exec.execute(waitPerson);
   }
   for (int i = 0; i < nChefs; i++) {
     Chef chef = new Chef(this);
     chefs.add(chef);
     exec.execute(chef);
   }
 }
 public void run() {
   try {
     while (!Thread.interrupted()) {
       // A new customer arrives; assign a WaitPerson:
       WaitPerson wp = waitPersons.get(rand.nextInt(waitPersons.size()));
       Customer c = new Customer(wp);
       exec.execute(c);
       TimeUnit.MILLISECONDS.sleep(100);
     }
   } catch (InterruptedException e) {
     print("Restaurant interrupted");
   }
   print("Restaurant closing");
 }