Program: 103344
Project: 103344
Buggy source:
/** 
 * The thread run method that handles idle notifies.
 * @see Thread#run()
 */
public void run(){
  while (running) {
    try {
      long idleTime=0;
      if (idleChangeListeners.size() > 0) {
        idleTime=SystemActivityNotifications.getLastInput();
        if (idleTime < idleStateCheckDelay && listenersInIdleState.size() > 0) {
          for (          SystemActivityChangeListener l : listenersInIdleState) {
            fireSystemIdleEndEvent(l);
          }
          listenersInIdleState.clear();
        }
        for (        Map.Entry<SystemActivityChangeListener,Long> entry : idleChangeListeners.entrySet()) {
          if (entry.getValue() <= idleTime) {
            fireSystemIdleEvent(entry.getKey());
            listenersInIdleState.add(entry.getKey());
          }
        }
      }
      if (listenersInIdleState.size() > 0) {
        idleStateCheckDelay=CHECK_FOR_IDLE_WHEN_IDLE;
      }
 else       if (idleTime != 0) {
        long minIdleSetting=Collections.min(idleChangeListeners.values());
        int newSetting=(int)(minIdleSetting - idleTime) + 1000;
        if (newSetting > 0)         idleStateCheckDelay=newSetting;
 else         idleStateCheckDelay=CHECK_FOR_IDLE_DEFAULT;
      }
 else {
        idleStateCheckDelay=CHECK_FOR_IDLE_DEFAULT;
      }
synchronized (this) {
        this.wait(idleStateCheckDelay);
      }
    }
 catch (    UnsatisfiedLinkError t) {
      logger.error("String_Node_Str",t);
      return;
    }
catch (    Throwable t) {
      logger.error("String_Node_Str",t);
    }
  }
}

Fixed version (ground truth):
/** 
 * The thread run method that handles idle notifies.
 * @see Thread#run()
 */
public void run(){
  while (running) {
    try {
      long idleTime=0;
      if (idleChangeListeners.size() > 0) {
        idleTime=SystemActivityNotifications.getLastInput();
        if (idleTime < idleStateCheckDelay && listenersInIdleState.size() > 0) {
          for (          SystemActivityChangeListener l : listenersInIdleState) {
            fireSystemIdleEndEvent(l);
          }
          listenersInIdleState.clear();
        }
        for (        Map.Entry<SystemActivityChangeListener,Long> entry : idleChangeListeners.entrySet()) {
          SystemActivityChangeListener listener=entry.getKey();
          if (listenersInIdleState.contains(listener))           continue;
          if (entry.getValue() <= idleTime) {
            fireSystemIdleEvent(listener);
            listenersInIdleState.add(listener);
          }
        }
      }
      if (listenersInIdleState.size() > 0) {
        idleStateCheckDelay=CHECK_FOR_IDLE_WHEN_IDLE;
      }
 else       if (idleTime != 0) {
        long minIdleSetting=Collections.min(idleChangeListeners.values());
        int newSetting=(int)(minIdleSetting - idleTime) + 1000;
        if (newSetting > 0)         idleStateCheckDelay=newSetting;
 else         idleStateCheckDelay=CHECK_FOR_IDLE_DEFAULT;
      }
 else {
        idleStateCheckDelay=CHECK_FOR_IDLE_DEFAULT;
      }
synchronized (this) {
        this.wait(idleStateCheckDelay);
      }
    }
 catch (    UnsatisfiedLinkError t) {
      logger.error("String_Node_Str",t);
      return;
    }
catch (    Throwable t) {
      logger.error("String_Node_Str",t);
    }
  }
}