Program: 20215
Project: 20215
Buggy source:
public void estimate() throws IOException {
  long startTime=System.currentTimeMillis();
  WorkerRunnable[] runnables=new WorkerRunnable[numThreads];
  int docsPerThread=data.size() / numThreads;
  int offset=0;
  for (int thread=0; thread < numThreads; thread++) {
    int[] runnableTotals=new int[numTopics];
    System.arraycopy(tokensPerTopic,0,runnableTotals,0,numTopics);
    int[][] runnableCounts=new int[numTypes][];
    for (int type=0; type < numTypes; type++) {
      int[] counts=new int[typeTopicCounts[type].length];
      System.arraycopy(typeTopicCounts[type],0,counts,0,counts.length);
      runnableCounts[type]=counts;
    }
    runnables[thread]=new WorkerRunnable(numTopics,alpha,alphaSum,beta,new Randoms(),data,runnableCounts,runnableTotals,offset,docsPerThread);
    runnables[thread].initializeAlphaStatistics(docLengthCounts.length);
    offset+=docsPerThread;
  }
  ExecutorService executor=Executors.newFixedThreadPool(numThreads);
  for (int iteration=1; iteration <= numIterations; iteration++) {
    long iterationStart=System.currentTimeMillis();
    if (showTopicsInterval != 0 && iteration != 0 && iteration % showTopicsInterval == 0) {
      System.out.println();
      printTopWords(System.out,wordsPerTopic,false);
    }
    if (saveStateInterval != 0 && iteration % saveStateInterval == 0) {
      this.printState(new File(stateFilename + '.' + iteration));
    }
    for (int thread=0; thread < numThreads; thread++) {
      if (iteration > burninPeriod && optimizeInterval != 0 && iteration % saveSampleInterval == 0) {
        runnables[thread].collectAlphaStatistics();
      }
      executor.submit(runnables[thread]);
    }
    try {
      Thread.sleep(20);
    }
 catch (    InterruptedException e) {
    }
    boolean finished=false;
    while (!finished) {
      try {
        Thread.sleep(10);
      }
 catch (      InterruptedException e) {
      }
      finished=true;
      for (int thread=0; thread < numThreads; thread++) {
        finished=finished && runnables[thread].isFinished;
      }
    }
    if (iteration > burninPeriod && optimizeInterval != 0 && iteration % optimizeInterval == 0) {
      optimizeAlpha(runnables);
      System.out.print("String_Node_Str" + (System.currentTimeMillis() - iterationStart) + "String_Node_Str");
    }
    System.out.print("String_Node_Str" + (System.currentTimeMillis() - iterationStart) + "String_Node_Str");
    sumTypeTopicCounts(runnables);
    System.out.print("String_Node_Str" + (System.currentTimeMillis() - iterationStart) + "String_Node_Str");
    for (int thread=0; thread < numThreads; thread++) {
      int[] runnableTotals=runnables[thread].getTokensPerTopic();
      System.arraycopy(tokensPerTopic,0,runnableTotals,0,numTopics);
      int[][] runnableCounts=runnables[thread].getTypeTopicCounts();
      for (int type=0; type < numTypes; type++) {
        int[] targetCounts=runnableCounts[type];
        int[] sourceCounts=typeTopicCounts[type];
        int index=0;
        while (index < sourceCounts.length) {
          if (sourceCounts[index] != 0) {
            targetCounts[index]=sourceCounts[index];
          }
 else           if (targetCounts[index] != 0) {
            targetCounts[index]=0;
          }
 else {
            break;
          }
          index++;
        }
      }
    }
    long elapsedMillis=System.currentTimeMillis() - iterationStart;
    if (elapsedMillis < 1000) {
      System.out.print(elapsedMillis + "String_Node_Str");
    }
 else {
      System.out.print((elapsedMillis / 1000) + "String_Node_Str");
    }
    if (iteration % 10 == 0) {
      System.out.println("String_Node_Str" + iteration + "String_Node_Str");
      if (printLogLikelihood)       System.out.println(modelLogLikelihood());
    }
    System.out.flush();
  }
  executor.shutdownNow();
  long seconds=Math.round((System.currentTimeMillis() - startTime) / 1000.0);
  long minutes=seconds / 60;
  seconds%=60;
  long hours=minutes / 60;
  minutes%=60;
  long days=hours / 24;
  hours%=24;
  System.out.print("String_Node_Str");
  if (days != 0) {
    System.out.print(days);
    System.out.print("String_Node_Str");
  }
  if (hours != 0) {
    System.out.print(hours);
    System.out.print("String_Node_Str");
  }
  if (minutes != 0) {
    System.out.print(minutes);
    System.out.print("String_Node_Str");
  }
  System.out.print(seconds);
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public void estimate() throws IOException {
  long startTime=System.currentTimeMillis();
  WorkerRunnable[] runnables=new WorkerRunnable[numThreads];
  int docsPerThread=data.size() / numThreads;
  int offset=0;
  for (int thread=0; thread < numThreads; thread++) {
    int[] runnableTotals=new int[numTopics];
    System.arraycopy(tokensPerTopic,0,runnableTotals,0,numTopics);
    int[][] runnableCounts=new int[numTypes][];
    for (int type=0; type < numTypes; type++) {
      int[] counts=new int[typeTopicCounts[type].length];
      System.arraycopy(typeTopicCounts[type],0,counts,0,counts.length);
      runnableCounts[type]=counts;
    }
    if (thread == numThreads - 1) {
      docsPerThread=data.size() - offset;
    }
    runnables[thread]=new WorkerRunnable(numTopics,alpha,alphaSum,beta,new Randoms(),data,runnableCounts,runnableTotals,offset,docsPerThread);
    runnables[thread].initializeAlphaStatistics(docLengthCounts.length);
    offset+=docsPerThread;
  }
  ExecutorService executor=Executors.newFixedThreadPool(numThreads);
  for (int iteration=1; iteration <= numIterations; iteration++) {
    long iterationStart=System.currentTimeMillis();
    if (showTopicsInterval != 0 && iteration != 0 && iteration % showTopicsInterval == 0) {
      System.out.println();
      printTopWords(System.out,wordsPerTopic,false);
    }
    if (saveStateInterval != 0 && iteration % saveStateInterval == 0) {
      this.printState(new File(stateFilename + '.' + iteration));
    }
    for (int thread=0; thread < numThreads; thread++) {
      if (iteration > burninPeriod && optimizeInterval != 0 && iteration % saveSampleInterval == 0) {
        runnables[thread].collectAlphaStatistics();
      }
      executor.submit(runnables[thread]);
    }
    try {
      Thread.sleep(20);
    }
 catch (    InterruptedException e) {
    }
    boolean finished=false;
    while (!finished) {
      try {
        Thread.sleep(10);
      }
 catch (      InterruptedException e) {
      }
      finished=true;
      for (int thread=0; thread < numThreads; thread++) {
        finished=finished && runnables[thread].isFinished;
      }
    }
    if (iteration > burninPeriod && optimizeInterval != 0 && iteration % optimizeInterval == 0) {
      optimizeAlpha(runnables);
      System.out.print("String_Node_Str" + (System.currentTimeMillis() - iterationStart) + "String_Node_Str");
    }
    System.out.print("String_Node_Str" + (System.currentTimeMillis() - iterationStart) + "String_Node_Str");
    sumTypeTopicCounts(runnables);
    System.out.print("String_Node_Str" + (System.currentTimeMillis() - iterationStart) + "String_Node_Str");
    for (int thread=0; thread < numThreads; thread++) {
      int[] runnableTotals=runnables[thread].getTokensPerTopic();
      System.arraycopy(tokensPerTopic,0,runnableTotals,0,numTopics);
      int[][] runnableCounts=runnables[thread].getTypeTopicCounts();
      for (int type=0; type < numTypes; type++) {
        int[] targetCounts=runnableCounts[type];
        int[] sourceCounts=typeTopicCounts[type];
        int index=0;
        while (index < sourceCounts.length) {
          if (sourceCounts[index] != 0) {
            targetCounts[index]=sourceCounts[index];
          }
 else           if (targetCounts[index] != 0) {
            targetCounts[index]=0;
          }
 else {
            break;
          }
          index++;
        }
      }
    }
    long elapsedMillis=System.currentTimeMillis() - iterationStart;
    if (elapsedMillis < 1000) {
      System.out.print(elapsedMillis + "String_Node_Str");
    }
 else {
      System.out.print((elapsedMillis / 1000) + "String_Node_Str");
    }
    if (iteration % 10 == 0) {
      System.out.println("String_Node_Str" + iteration + "String_Node_Str");
      if (printLogLikelihood)       System.out.println(modelLogLikelihood());
    }
    System.out.flush();
  }
  executor.shutdownNow();
  long seconds=Math.round((System.currentTimeMillis() - startTime) / 1000.0);
  long minutes=seconds / 60;
  seconds%=60;
  long hours=minutes / 60;
  minutes%=60;
  long days=hours / 24;
  hours%=24;
  System.out.print("String_Node_Str");
  if (days != 0) {
    System.out.print(days);
    System.out.print("String_Node_Str");
  }
  if (hours != 0) {
    System.out.print(hours);
    System.out.print("String_Node_Str");
  }
  if (minutes != 0) {
    System.out.print(minutes);
    System.out.print("String_Node_Str");
  }
  System.out.print(seconds);
  System.out.println("String_Node_Str");
}