Program: 75814
Project: 75814
Buggy source:
/** 
 * Dequeue the events from the event queue that have the smallest time stamp and depth. Advance the model time to their time stamp, and mark the destination actor for firing. If the time stamp is greater than the stop time then return null. If there are no events on the event queue, and _stopWhenQueueIsEmpty flag is true (which is set to true by default) then return null, which will have the effect of stopping the simulation. If _stopWhenQueueIsEmpty is false and the queue is empty, then stall the current thread by calling wait() on the _eventQueue until there are events available.  If _synchronizeToRealTime is true, then this method may suspend the calling thread using Object.wait(long) to let elapsed real time catch up with the current event.
 * @return The next actor to fire.
 */
protected Actor _dequeueEvents(){
  Actor actorToFire=null;
  DEEvent currentEvent=null, nextEvent=null;
  int currentDepth=0;
  if (_eventQueue == null)   return null;
  while (true) {
    if (_stopWhenQueueIsEmpty) {
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
 else {
      if (actorToFire != null && _eventQueue.isEmpty())       break;
      while (_eventQueue.isEmpty() && !_stopRequested) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        Thread.currentThread().yield();
synchronized (_eventQueue) {
          try {
            _eventQueue.wait();
          }
 catch (          InterruptedException e) {
            break;
          }
        }
      }
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
    if (actorToFire == null) {
      _eventQueue.take();
      currentEvent=nextEvent;
      actorToFire=currentEvent.actor();
      if (_disabledActors != null && _disabledActors.contains(actorToFire)) {
        if (_debugging)         _debug("String_Node_Str",((Nameable)actorToFire).getFullName());
        actorToFire=null;
        continue;
      }
      double currentTime=currentEvent.timeStamp();
      if (_synchronizeToRealTime) {
        long elapsedTime=System.currentTimeMillis() - _realStartTime;
        double elapsedTimeInSeconds=((double)elapsedTime) / 1000.0;
        if (currentTime > elapsedTimeInSeconds) {
          long timeToWait=(long)((currentTime - elapsedTimeInSeconds) * 1000.0);
          if (timeToWait > 0) {
            if (_debugging) {
              _debug("String_Node_Str" + timeToWait);
            }
synchronized (_eventQueue) {
              try {
                _eventQueue.wait(timeToWait);
              }
 catch (              InterruptedException ex) {
              }
            }
          }
        }
      }
      if (_debugging)       _debug("String_Node_Str",Double.toString(currentTime));
      try {
        setCurrentTime(currentTime);
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex.toString());
      }
      currentDepth=currentEvent.depth();
      _microstep=currentEvent.microstep();
      if (currentTime > getStopTime()) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        _exceedStopTime=true;
        return null;
      }
      DEReceiver receiver=currentEvent.receiver();
      if (receiver != null) {
        if (_debugging)         _debug(getName(),"String_Node_Str",receiver.getContainer().getFullName());
        receiver._triggerEvent(currentEvent.token());
      }
    }
 else {
      if (nextEvent.isSimultaneousWith(currentEvent) && nextEvent.actor() == currentEvent.actor()) {
        _eventQueue.take();
        DEReceiver receiver=nextEvent.receiver();
        if (receiver != null) {
          receiver._triggerEvent(nextEvent.token());
        }
      }
 else {
        break;
      }
    }
  }
  return actorToFire;
}

Fixed version (ground truth):
/** 
 * Dequeue the events from the event queue that have the smallest time stamp and depth. Advance the model time to their time stamp, and mark the destination actor for firing. If the time stamp is greater than the stop time then return null. If there are no events on the event queue, and _stopWhenQueueIsEmpty flag is true (which is set to true by default) then return null, which will have the effect of stopping the simulation. If _stopWhenQueueIsEmpty is false and the queue is empty, then stall the current thread by calling wait() on the _eventQueue until there are events available.  If _synchronizeToRealTime is true, then this method may suspend the calling thread using Object.wait(long) to let elapsed real time catch up with the current event.
 * @return The next actor to fire.
 */
protected Actor _dequeueEvents(){
  Actor actorToFire=null;
  DEEvent currentEvent=null, nextEvent=null;
  int currentDepth=0;
  if (_eventQueue == null)   return null;
  while (true) {
    if (_stopWhenQueueIsEmpty) {
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
 else {
      if (actorToFire != null && _eventQueue.isEmpty())       break;
      while (_eventQueue.isEmpty() && !_stopRequested) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        Thread.currentThread().yield();
synchronized (_eventQueue) {
          try {
            _eventQueue.wait();
          }
 catch (          InterruptedException e) {
            break;
          }
        }
      }
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
    if (actorToFire == null) {
      currentEvent=nextEvent;
      double currentTime=currentEvent.timeStamp();
      if (_synchronizeToRealTime) {
        long elapsedTime=System.currentTimeMillis() - _realStartTime;
        double elapsedTimeInSeconds=((double)elapsedTime) / 1000.0;
        if (currentTime > elapsedTimeInSeconds) {
          long timeToWait=(long)((currentTime - elapsedTimeInSeconds) * 1000.0);
          if (timeToWait > 0) {
            if (_debugging) {
              _debug("String_Node_Str" + timeToWait);
            }
synchronized (_eventQueue) {
              try {
                _eventQueue.wait(timeToWait);
              }
 catch (              InterruptedException ex) {
              }
            }
          }
        }
      }
      currentEvent=(DEEvent)_eventQueue.take();
      currentTime=currentEvent.timeStamp();
      actorToFire=currentEvent.actor();
      if (_disabledActors != null && _disabledActors.contains(actorToFire)) {
        if (_debugging)         _debug("String_Node_Str",((Nameable)actorToFire).getFullName());
        actorToFire=null;
        continue;
      }
      if (_debugging)       _debug("String_Node_Str",Double.toString(currentTime));
      try {
        setCurrentTime(currentTime);
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex.toString());
      }
      currentDepth=currentEvent.depth();
      _microstep=currentEvent.microstep();
      if (currentTime > getStopTime()) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        _exceedStopTime=true;
        return null;
      }
      DEReceiver receiver=currentEvent.receiver();
      if (receiver != null) {
        if (_debugging)         _debug(getName(),"String_Node_Str",receiver.getContainer().getFullName());
        receiver._triggerEvent(currentEvent.token());
      }
    }
 else {
      if (nextEvent.isSimultaneousWith(currentEvent) && nextEvent.actor() == currentEvent.actor()) {
        _eventQueue.take();
        DEReceiver receiver=nextEvent.receiver();
        if (receiver != null) {
          receiver._triggerEvent(nextEvent.token());
        }
      }
 else {
        break;
      }
    }
  }
  return actorToFire;
}