Program: 75742
Project: 75742
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();
        if (_debugging) {
          _debug("String_Node_Str");
        }
synchronized (_eventQueue) {
          if (_eventQueue.isEmpty()) {
            try {
              if (_debugging) {
                _debug("String_Node_Str");
              }
              _eventQueue.wait();
              if (_debugging) {
                _debug("String_Node_Str");
              }
            }
 catch (            InterruptedException e) {
              if (_debugging) {
                _debug("String_Node_Str" + "String_Node_Str");
              }
              break;
            }
catch (            Exception e) {
              if (_debugging) {
                _debug("String_Node_Str");
              }
            }
          }
        }
      }
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
    if (actorToFire == null) {
      double currentTime;
      if (!_synchronizeToRealTime) {
        currentEvent=(DEEvent)_eventQueue.get();
        currentTime=currentEvent.timeStamp();
      }
 else {
synchronized (_eventQueue) {
          while (true) {
            currentEvent=(DEEvent)_eventQueue.get();
            currentTime=currentEvent.timeStamp();
            long elapsedTime=System.currentTimeMillis() - _realStartTime;
            double elapsedTimeInSeconds=((double)elapsedTime) / 1000.0;
            if (currentTime <= elapsedTimeInSeconds) {
              break;
            }
            long timeToWait=(long)((currentTime - elapsedTimeInSeconds) * 1000.0);
            if (timeToWait > 0) {
              if (_debugging) {
                _debug("String_Node_Str" + timeToWait);
              }
              try {
                _eventQueue.wait(timeToWait);
              }
 catch (              InterruptedException ex) {
              }
            }
          }
        }
      }
synchronized (_eventQueue) {
        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;
        }
        try {
          setCurrentTime(currentTime);
        }
 catch (        IllegalActionException ex) {
          throw new InternalErrorException(this,ex,null);
        }
      }
      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 (!_stopRequested) {
    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();
        if (_debugging) {
          _debug("String_Node_Str");
        }
synchronized (_eventQueue) {
          if (_eventQueue.isEmpty()) {
            try {
              if (_debugging) {
                _debug("String_Node_Str");
              }
              _eventQueue.wait();
              if (_debugging) {
                _debug("String_Node_Str");
              }
            }
 catch (            InterruptedException e) {
              if (_debugging) {
                _debug("String_Node_Str" + "String_Node_Str");
              }
              break;
            }
catch (            Exception e) {
              if (_debugging) {
                _debug("String_Node_Str");
              }
            }
          }
        }
      }
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
    if (actorToFire == null) {
      double currentTime;
      if (!_synchronizeToRealTime) {
        currentEvent=(DEEvent)_eventQueue.get();
        currentTime=currentEvent.timeStamp();
      }
 else {
synchronized (_eventQueue) {
          while (true) {
            currentEvent=(DEEvent)_eventQueue.get();
            currentTime=currentEvent.timeStamp();
            long elapsedTime=System.currentTimeMillis() - _realStartTime;
            double elapsedTimeInSeconds=((double)elapsedTime) / 1000.0;
            if (currentTime <= elapsedTimeInSeconds) {
              break;
            }
            long timeToWait=(long)((currentTime - elapsedTimeInSeconds) * 1000.0);
            if (timeToWait > 0) {
              if (_debugging) {
                _debug("String_Node_Str" + timeToWait);
              }
              try {
                _eventQueue.wait(timeToWait);
              }
 catch (              InterruptedException ex) {
              }
            }
          }
        }
      }
synchronized (_eventQueue) {
        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;
        }
        try {
          setCurrentTime(currentTime);
        }
 catch (        IllegalActionException ex) {
          throw new InternalErrorException(this,ex,null);
        }
      }
      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;
}