protected boolean pickAndExecuteAnAction() {

    synchronized (orders) {
      for (Order o : orders) {
        if (o.state == OrderState.UnableToBeSupplied) {
          TellWaiterWeAreOut(o);
          return true;
        }
      }
    }
    synchronized (orders) {
      for (Order o : orders) {
        if (o.state == OrderState.NotReady) {
          o.state = OrderState.BeingPrepared;
          PrepareOrder(o);
          return true;
        }
      }
    }
    synchronized (orders) {
      for (Order o : orders) {
        if (o.state == OrderState.Ready) {
          OrderIsReady(o);
          return true;
        }
      }
    }
    synchronized (marketOrders) {
      for (MarketOrder mo : marketOrders) {
        if (mo.os == moState.pending) {
          print("Ordering " + mo.amount + " " + mo.food + "'s");
          mo.os = moState.ordered;
          print("COWABUNGA ordering from market");
          goToMarket(restaurant, "Italian", mo.amount, mo.id);
          return true;
        }
      }
    }
    // Producer-consumer handling
    StandOrder orderFromStand = restaurant.revolvingStand.remove();
    if (orderFromStand != null) {

      WaiterAgent standWaiter = orderFromStand.waiter;
      int standTableNum = orderFromStand.tableNum;
      String standOrderType = orderFromStand.order;

      if (menu.menuItems.containsKey(orderFromStand.order)
          && inventory.get(orderFromStand.order) > 0) {
        long timeFinish =
            (System.currentTimeMillis()
                + (long) ((menu.menuItems.get(standOrderType)) * Constants.SECOND));
        Order newStandOrder = new Order(standWaiter, standTableNum, standOrderType, timeFinish);
        AddNewOrderFromStand(newStandOrder);
      }
      return true;
    }
    return false;
  }
 public void msgHereIsOrder(String choice, int amount, int id) {
   print("Received a delivery of " + amount + " " + choice + "'s from the market!");
   for (int i = 0; i < marketOrders.size(); i++) {
     MarketOrder mo = marketOrders.get(i);
     if (mo.id == id && mo.amount == amount) {
       Food f = findFood(mo.food);
       f.amount = amount;
       print("removing a market order whee");
       marketOrders.remove(mo);
     } else if (mo.food == choice && mo.amount != 0) {
       Food f = findFood(mo.food);
       f.amount = amount + mo.amount;
       mo.amount -= amount;
     }
   }
 }