/**
   * Update the waiting threads according to the wakeup reason (dispatched element). The
   * corresponding waiting activity/thread is notified.
   */
  public void updateWaitingThreads() {
    if (waittimes != null) {
      //			IClockService clock =
      // (IClockService)interpreter.getServiceProvider().getService(IClockService.class);

      IClockService clock = interpreter.getClockService();
      for (Iterator it = waittimes.keySet().iterator(); it.hasNext(); ) {
        ProcessThread thread = (ProcessThread) it.next();
        if (((Number) waittimes.get(thread)).longValue() <= clock.getTime()) {
          it.remove();
          assert thread.isWaiting();
          BpmnPlanBodyInstance.this.notify(
              thread.getActivity(),
              thread,
              AbstractEventIntermediateTimerActivityHandler.TIMER_EVENT);
        }
      }
    }

    Object dispelem = state.getAttributeValue(rplan, OAVBDIRuntimeModel.plan_has_dispatchedelement);
    //		System.out.println("dispatched: "+dispelem);

    if (dispelem != null) {
      for (Iterator it = context.getAllThreads().iterator(); it.hasNext(); ) {
        ProcessThread thread = (ProcessThread) it.next();
        try {
          if (thread.isWaiting() && thread.getWaitFilter().filter(dispelem)) {
            BpmnPlanBodyInstance.this.notify(thread.getActivity(), thread, getFlyweight(dispelem));
          }
        } catch (Exception e) {
          // just catch filter exceptions.
        }
      }
    }
  }