Program: 60774
Project: 60774
Buggy source:
private boolean runInternal(){
  int size=mPageStateArray.length;
  int index;
  boolean force=false;
synchronized (mRequestPageQueue) {
    if (!mForceRequestPageQueue.isEmpty()) {
      index=mForceRequestPageQueue.remove();
      force=true;
    }
 else     if (!mRequestPageQueue.isEmpty()) {
      index=mRequestPageQueue.remove();
    }
 else     if (!mRequestPageQueue2.isEmpty()) {
      index=mRequestPageQueue2.remove();
    }
 else     if (mDownloadPage >= 0 && mDownloadPage < size) {
      index=mDownloadPage;
      mDownloadPage++;
    }
 else {
      return false;
    }
    if (index < 0 || index >= size) {
      return true;
    }
  }
synchronized (mPageStateLock) {
    int state=mPageStateArray[index];
    if (state == STATE_DOWNLOADING || (!force && (state == STATE_FINISHED || state == STATE_FAILED))) {
      return true;
    }
    updatePageState(index,STATE_DOWNLOADING);
  }
  if (!force && mSpiderDen.contain(index)) {
    updatePageState(index,STATE_FINISHED);
    return true;
  }
  if (force) {
synchronized (mPTokenLock) {
      int i=mSpiderInfo.pTokenMap.indexOfKey(index);
      String pToken=mSpiderInfo.pTokenMap.valueAt(i);
      if (SpiderInfo.TOKEN_FAILED.equals(pToken)) {
        mSpiderInfo.pTokenMap.setValueAt(i,null);
      }
    }
  }
  String pToken=null;
  while (!Thread.currentThread().isInterrupted()) {
synchronized (mPTokenLock) {
      pToken=mSpiderInfo.pTokenMap.get(index);
    }
    if (pToken == null) {
      mRequestPTokenQueue.add(index);
synchronized (mQueenLock) {
        mQueenLock.notify();
      }
synchronized (mWorkerLock) {
        try {
          mWorkerLock.wait();
        }
 catch (        InterruptedException e) {
          if (DEBUG_LOG) {
            Log.d(TAG,Thread.currentThread().getName() + "String_Node_Str");
          }
          break;
        }
      }
    }
 else {
      break;
    }
  }
  if (pToken == null) {
    updatePageState(index,STATE_FAILED,null);
    return false;
  }
  if (SpiderInfo.TOKEN_FAILED.equals(pToken)) {
    updatePageState(index,STATE_FAILED,GetText.getString(R.string.error_get_ptoken_error));
    return true;
  }
  return downloadImage(mGid,index,pToken,force);
}

Fixed version (ground truth):
private boolean runInternal(){
  int size=mPageStateArray.length;
  int index;
  boolean force=false;
synchronized (mRequestPageQueue) {
    if (!mForceRequestPageQueue.isEmpty()) {
      index=mForceRequestPageQueue.remove();
      force=true;
    }
 else     if (!mRequestPageQueue.isEmpty()) {
      index=mRequestPageQueue.remove();
    }
 else     if (!mRequestPageQueue2.isEmpty()) {
      index=mRequestPageQueue2.remove();
    }
 else     if (mDownloadPage >= 0 && mDownloadPage < size) {
      index=mDownloadPage;
      mDownloadPage++;
    }
 else {
      return false;
    }
    if (index < 0 || index >= size) {
      return true;
    }
  }
synchronized (mPageStateLock) {
    int state=mPageStateArray[index];
    if (state == STATE_DOWNLOADING || (!force && (state == STATE_FINISHED || state == STATE_FAILED))) {
      return true;
    }
    updatePageState(index,STATE_DOWNLOADING);
  }
  if (!force && mSpiderDen.contain(index)) {
    Log.d("String_Node_Str","String_Node_Str");
    updatePageState(index,STATE_FINISHED);
    return true;
  }
  if (force) {
synchronized (mPTokenLock) {
      int i=mSpiderInfo.pTokenMap.indexOfKey(index);
      String pToken=mSpiderInfo.pTokenMap.valueAt(i);
      if (SpiderInfo.TOKEN_FAILED.equals(pToken)) {
        mSpiderInfo.pTokenMap.setValueAt(i,null);
      }
    }
  }
  String pToken=null;
  while (!Thread.currentThread().isInterrupted()) {
synchronized (mPTokenLock) {
      pToken=mSpiderInfo.pTokenMap.get(index);
    }
    if (pToken == null) {
      mRequestPTokenQueue.add(index);
synchronized (mQueenLock) {
        mQueenLock.notify();
      }
synchronized (mWorkerLock) {
        try {
          mWorkerLock.wait();
        }
 catch (        InterruptedException e) {
          if (DEBUG_LOG) {
            Log.d(TAG,Thread.currentThread().getName() + "String_Node_Str");
          }
          break;
        }
      }
    }
 else {
      break;
    }
  }
  if (pToken == null) {
    updatePageState(index,STATE_FAILED,null);
    return false;
  }
  if (SpiderInfo.TOKEN_FAILED.equals(pToken)) {
    updatePageState(index,STATE_FAILED,GetText.getString(R.string.error_get_ptoken_error));
    return true;
  }
  return downloadImage(mGid,index,pToken,force);
}