Program: 22774
Project: 22774
Buggy source:
/** 
 * Get probability distribution of each class for current classifier  and specific image data (multi-thread version)
 * @param data input data set
 * @param width image width
 * @param height image height
 * @return probability stack, one image per class
 */
public ImagePlus getProbabilityMapsMT(Instances data,final int width,final int height){
  if (this.classifier == null)   return null;
  final int nClasses=data.numClasses();
  final ImageStack is=new ImageStack(width,height);
  final FloatProcessor[] classProb=new FloatProcessor[nClasses];
  for (int k=0; k < nClasses; k++)   classProb[k]=new FloatProcessor(width,height);
  IJ.log("String_Node_Str");
  final int numOfProcessors=Runtime.getRuntime().availableProcessors();
  final ExecutorService exe=Executors.newFixedThreadPool(numOfProcessors);
  final ArrayList<Future<double[][]>> futures=new ArrayList<Future<double[][]>>();
  final Instances[] partialData=new Instances[numOfProcessors];
  final int partialSize=data.numInstances() / numOfProcessors;
  final Rectangle[] rects=new Rectangle[numOfProcessors];
  ImagePlus result=null;
  try {
    int block_height=height / numOfProcessors;
    if (height % 2 != 0)     block_height++;
    for (int i=0; i < numOfProcessors; i++) {
      if (i == numOfProcessors - 1) {
        partialData[i]=new Instances(data,i * partialSize,data.numInstances() - i * partialSize);
        block_height=height - i * block_height;
      }
 else {
        partialData[i]=new Instances(data,i * partialSize,partialSize);
      }
      int y_start=i * block_height;
      rects[i]=new Rectangle(0,y_start,width,block_height);
      futures.add(exe.submit(getDistributionForIntances(partialData[i],this.classifier)));
    }
    for (int index=0; index < futures.size(); index++) {
      final double[][] partialProb=futures.get(index).get();
      for (int k=0; k < nClasses; k++)       classProb[k].insert(new FloatProcessor(width,block_height,partialProb[k]),rects[index].x,rects[index].y);
    }
    for (int k=0; k < nClasses; k++)     is.addSlice("String_Node_Str" + (k + 1),classProb[k]);
    result=new ImagePlus("String_Node_Str",is);
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
  }
 finally {
    exe.shutdown();
  }
  IJ.log("String_Node_Str");
  return result;
}

Fixed version (ground truth):
/** 
 * Get probability distribution of each class for current classifier  and specific image data (multi-thread version)
 * @param data input data set
 * @param width image width
 * @param height image height
 * @return probability stack, one image per class
 */
public ImagePlus getProbabilityMapsMT(Instances data,final int width,final int height){
  if (this.classifier == null)   return null;
  final int nClasses=data.numClasses();
  final ImageStack is=new ImageStack(width,height);
  final FloatProcessor[] classProb=new FloatProcessor[nClasses];
  for (int k=0; k < nClasses; k++)   classProb[k]=new FloatProcessor(width,height);
  final int numOfProcessors=Runtime.getRuntime().availableProcessors();
  final ExecutorService exe=Executors.newFixedThreadPool(numOfProcessors);
  final ArrayList<Future<double[][]>> futures=new ArrayList<Future<double[][]>>();
  final Instances[] partialData=new Instances[numOfProcessors];
  final int partialSize=data.numInstances() / numOfProcessors;
  final Rectangle[] rects=new Rectangle[numOfProcessors];
  ImagePlus result=null;
  try {
    int block_height=height / numOfProcessors;
    if (height % 2 != 0)     block_height++;
    for (int i=0; i < numOfProcessors; i++) {
      if (i == numOfProcessors - 1) {
        partialData[i]=new Instances(data,i * partialSize,data.numInstances() - i * partialSize);
        block_height=height - i * block_height;
      }
 else {
        partialData[i]=new Instances(data,i * partialSize,partialSize);
      }
      int y_start=i * block_height;
      rects[i]=new Rectangle(0,y_start,width,block_height);
      futures.add(exe.submit(getDistributionForIntances(partialData[i],this.classifier)));
    }
    for (int index=0; index < futures.size(); index++) {
      final double[][] partialProb=futures.get(index).get();
      for (int k=0; k < nClasses; k++)       classProb[k].insert(new FloatProcessor(width,block_height,partialProb[k]),rects[index].x,rects[index].y);
    }
    for (int k=0; k < nClasses; k++)     is.addSlice("String_Node_Str" + (k + 1),classProb[k]);
    result=new ImagePlus("String_Node_Str",is);
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
  }
 finally {
    exe.shutdown();
  }
  IJ.log("String_Node_Str");
  return result;
}