Program: 75446
Project: 75446
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;
  if (_eventQueue == null)   return null;
  while (!_stopRequested) {
    if (_stopWhenQueueIsEmpty) {
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
 else     if (!_isTopLevel() && _eventQueue.isEmpty()) {
      break;
    }
 else {
      if (actorToFire != null && _eventQueue.isEmpty())       break;
      while (_eventQueue.isEmpty() && !_stopRequested) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        Thread.yield();
synchronized (_eventQueue) {
          if (_eventQueue.isEmpty()) {
            try {
              _eventQueue.wait();
            }
 catch (            InterruptedException e) {
              break;
            }
catch (            Exception e) {
              if (_debugging) {
                _debug(e.toString());
              }
            }
          }
        }
      }
      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 (currentTime == Double.NEGATIVE_INFINITY) {
          currentTime=getCurrentTime();
        }
        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);
        }
      }
      _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.timeStamp() == Double.NEGATIVE_INFINITY || 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;
  if (_eventQueue == null)   return null;
  while (!_stopRequested) {
    if (_stopWhenQueueIsEmpty) {
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
 else     if (!_isTopLevel() && _eventQueue.isEmpty()) {
      break;
    }
 else {
      if (actorToFire != null && _eventQueue.isEmpty())       break;
      while (_eventQueue.isEmpty() && !_stopRequested) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        Thread.yield();
synchronized (_eventQueue) {
          if (_eventQueue.isEmpty()) {
            try {
              workspace().wait(_eventQueue);
            }
 catch (            InterruptedException e) {
              break;
            }
catch (            Exception e) {
              if (_debugging) {
                _debug(e.toString());
              }
            }
          }
        }
      }
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
    if (!_isTopLevel() && _eventQueue.get().timeStamp() > getCurrentTime()) {
      break;
    }
    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 (currentTime == Double.NEGATIVE_INFINITY) {
          currentTime=getCurrentTime();
        }
        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);
        }
      }
      _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.timeStamp() == Double.NEGATIVE_INFINITY || nextEvent.isSimultaneousWith(currentEvent)) && nextEvent.actor() == currentEvent.actor()) {
        _eventQueue.take();
        DEReceiver receiver=nextEvent.receiver();
        if (receiver != null) {
          receiver._triggerEvent(nextEvent.token());
        }
      }
 else {
        break;
      }
    }
  }
  return actorToFire;
}