Program: 22738
Project: 22738
Buggy source:
/** 
 * Update features with current list in a multi-thread fashion
 * @return true if the features are correctly updated 
 */
public boolean updateFeaturesMT(){
  if (Thread.currentThread().isInterrupted())   return false;
  exe=Executors.newFixedThreadPool(Prefs.getThreads());
  wholeStack=new ImageStack(width,height);
  if (originalImage.getType() == ImagePlus.COLOR_RGB)   wholeStack.addSlice("String_Node_Str",originalImage.getProcessor().duplicate());
 else   wholeStack.addSlice("String_Node_Str",originalImage.getProcessor().duplicate().convertToFloat());
  int finalIndex=0;
  for (int i=0; i < enableFeatures.length; i++)   if (enableFeatures[i])   finalIndex++;
  final ArrayList<Future<ImagePlus>> futures=new ArrayList<Future<ImagePlus>>();
  int currentIndex=0;
  IJ.showStatus("String_Node_Str");
  try {
    if (enableFeatures[ANISOTROPIC_DIFFUSION]) {
      for (float i=minimumSigma; i <= maximumSigma; i*=2)       for (float j=0.10f; j < 0.5f; j+=0.25f) {
        if (Thread.currentThread().isInterrupted())         return false;
        futures.add(exe.submit(getAnisotropicDiffusion(originalImage,20,20,(int)i,j,0.9f,(float)membraneSize)));
      }
    }
    if (originalImage.getType() == ImagePlus.COLOR_RGB)     futures.add(exe.submit(getHSB(originalImage)));
    if (enableFeatures[BILATERAL]) {
      for (double i=5; i < 20; i*=2)       for (double j=50; j <= 100; j*=2) {
        if (Thread.currentThread().isInterrupted())         return false;
        futures.add(exe.submit(getBilateralFilter(originalImage,i,j)));
      }
    }
    if (enableFeatures[LIPSCHITZ]) {
      for (double i=5; i < 30; i+=5) {
        if (Thread.currentThread().isInterrupted())         return false;
        futures.add(exe.submit(getLipschitzFilter(originalImage,true,true,i)));
      }
    }
    if (enableFeatures[KUWAHARA]) {
      for (int i=0; i < 3; i++) {
        if (Thread.currentThread().isInterrupted())         return false;
        futures.add(exe.submit(getKuwaharaFeatures(originalImage,membranePatchSize,nAngles,i)));
      }
    }
    if (enableFeatures[GABOR]) {
      for (int i=0; i < 2; i++)       for (double gamma=1; gamma >= 0.25; gamma/=2)       for (int frequency=2; frequency < 3; frequency++) {
        if (Thread.currentThread().isInterrupted())         return false;
        final double psi=Math.PI / 2 * i;
        futures.add(exe.submit(getGabor(originalImage,1.0,gamma,psi,frequency,nAngles)));
      }
      for (int i=0; i < 2; i++)       for (double sigma=2.0; sigma <= 4.0; sigma*=2)       for (double gamma=1.0; gamma <= 2.0; gamma*=2)       for (int frequency=2; frequency <= 3; frequency++) {
        if (Thread.currentThread().isInterrupted())         return false;
        final double psi=Math.PI / 2 * i;
        futures.add(exe.submit(getGabor(originalImage,sigma,gamma,psi,frequency,nAngles)));
      }
    }
    if (enableFeatures[SOBEL]) {
      if (Thread.currentThread().isInterrupted())       return false;
      futures.add(exe.submit(getGradient(originalImage,0)));
    }
    if (enableFeatures[HESSIAN]) {
      if (Thread.currentThread().isInterrupted())       return false;
      futures.add(exe.submit(getHessian(originalImage,0)));
    }
    for (float i=minimumSigma; i <= maximumSigma; i*=2) {
      if (Thread.currentThread().isInterrupted())       return false;
      if (enableFeatures[GAUSSIAN]) {
        futures.add(exe.submit(getGaussianBlur(originalImage,i)));
      }
      if (enableFeatures[SOBEL]) {
        futures.add(exe.submit(getGradient(originalImage,i)));
      }
      if (enableFeatures[HESSIAN]) {
        futures.add(exe.submit(getHessian(originalImage,i)));
      }
      if (enableFeatures[DOG]) {
        for (float j=minimumSigma; j < i; j*=2) {
          futures.add(exe.submit(getDoG(originalImage,i,j)));
        }
      }
      if (enableFeatures[VARIANCE]) {
        futures.add(exe.submit(getVariance(originalImage,i)));
      }
      if (enableFeatures[MEAN]) {
        futures.add(exe.submit(getMean(originalImage,i)));
      }
      if (enableFeatures[MINIMUM]) {
        futures.add(exe.submit(getMin(originalImage,i)));
      }
      if (enableFeatures[MAXIMUM]) {
        futures.add(exe.submit(getMax(originalImage,i)));
      }
      if (enableFeatures[MEDIAN]) {
        futures.add(exe.submit(getMedian(originalImage,i)));
      }
      if (enableFeatures[DERIVATIVES]) {
        for (int order=minDerivativeOrder; order <= maxDerivativeOrder; order++)         futures.add(exe.submit(getDerivatives(originalImage,i,order,order)));
      }
      if (enableFeatures[LAPLACIAN]) {
        futures.add(exe.submit(getLaplacian(originalImage,i)));
      }
      if (enableFeatures[STRUCTURE]) {
        for (int integrationScale=1; integrationScale <= 3; integrationScale+=2)         futures.add(exe.submit(getStructure(originalImage,i,integrationScale)));
      }
      if (enableFeatures[ENTROPY]) {
        for (int nBins=32; nBins <= 256; nBins*=2)         futures.add(exe.submit(getEntropy(originalImage,(int)i,nBins)));
      }
    }
    if (enableFeatures[MEMBRANE]) {
      if (Thread.currentThread().isInterrupted())       return false;
      futures.add(exe.submit(getMembraneFeatures(originalImage,membranePatchSize,membraneSize)));
    }
    for (    Future<ImagePlus> f : futures) {
      final ImagePlus res=f.get();
      currentIndex++;
      IJ.showStatus("String_Node_Str");
      IJ.showProgress(currentIndex,finalIndex);
      if (res.getImageStackSize() == 1) {
        this.wholeStack.addSlice(res.getTitle(),res.getProcessor());
      }
 else {
        final ImageStack slices=res.getImageStack();
        for (int i=1; i <= slices.getSize(); i++)         this.wholeStack.addSlice(slices.getSliceLabel(i),slices.getProcessor(i));
      }
    }
  }
 catch (  InterruptedException ie) {
    IJ.log("String_Node_Str");
    return false;
  }
catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
    return false;
  }
 finally {
    exe.shutdownNow();
  }
  IJ.showProgress(1.0);
  IJ.showStatus("String_Node_Str");
  return true;
}

Fixed version (ground truth):
/** 
 * Update features with current list in a multi-thread fashion
 * @return true if the features are correctly updated 
 */
public boolean updateFeaturesMT(){
  if (Thread.currentThread().isInterrupted())   return false;
  exe=Executors.newFixedThreadPool(Prefs.getThreads());
  wholeStack=new ImageStack(width,height);
  if (originalImage.getType() == ImagePlus.COLOR_RGB)   wholeStack.addSlice("String_Node_Str",originalImage.getProcessor().duplicate());
 else   wholeStack.addSlice("String_Node_Str",originalImage.getProcessor().duplicate().convertToFloat());
  int finalIndex=0;
  for (int i=0; i < enableFeatures.length; i++)   if (enableFeatures[i])   finalIndex++;
  final ArrayList<Future<ImagePlus>> futures=new ArrayList<Future<ImagePlus>>();
  int currentIndex=0;
  IJ.showStatus("String_Node_Str");
  try {
    if (enableFeatures[ANISOTROPIC_DIFFUSION]) {
      for (float i=minimumSigma; i <= maximumSigma; i*=2)       for (float j=0.10f; j < 0.5f; j+=0.25f) {
        if (Thread.currentThread().isInterrupted())         return false;
        futures.add(exe.submit(getAnisotropicDiffusion(originalImage,20,20,(int)i,j,0.9f,(float)membraneSize)));
      }
    }
    if (originalImage.getType() == ImagePlus.COLOR_RGB)     futures.add(exe.submit(getHSB(originalImage)));
    if (enableFeatures[BILATERAL]) {
      for (double i=5; i < 20; i*=2)       for (double j=50; j <= 100; j*=2) {
        if (Thread.currentThread().isInterrupted())         return false;
        futures.add(exe.submit(getBilateralFilter(originalImage,i,j)));
      }
    }
    if (enableFeatures[LIPSCHITZ]) {
      for (double i=5; i < 30; i+=5) {
        if (Thread.currentThread().isInterrupted())         return false;
        futures.add(exe.submit(getLipschitzFilter(originalImage,true,true,i)));
      }
    }
    if (enableFeatures[KUWAHARA]) {
      for (int i=0; i < 3; i++) {
        if (Thread.currentThread().isInterrupted())         return false;
        futures.add(exe.submit(getKuwaharaFeatures(originalImage,membranePatchSize,nAngles,i)));
      }
    }
    if (enableFeatures[GABOR]) {
      for (int i=0; i < 2; i++)       for (double gamma=1; gamma >= 0.25; gamma/=2)       for (int frequency=2; frequency < 3; frequency++) {
        if (Thread.currentThread().isInterrupted())         return false;
        final double psi=Math.PI / 2 * i;
        futures.add(exe.submit(getGabor(originalImage,1.0,gamma,psi,frequency,nAngles)));
      }
      for (int i=0; i < 2; i++)       for (double sigma=2.0; sigma <= 4.0; sigma*=2)       for (double gamma=1.0; gamma <= 2.0; gamma*=2)       for (int frequency=2; frequency <= 3; frequency++) {
        if (Thread.currentThread().isInterrupted())         return false;
        final double psi=Math.PI / 2 * i;
        futures.add(exe.submit(getGabor(originalImage,sigma,gamma,psi,frequency,nAngles)));
      }
    }
    if (enableFeatures[SOBEL] && minimumSigma < 2) {
      if (Thread.currentThread().isInterrupted())       return false;
      futures.add(exe.submit(getGradient(originalImage,0)));
    }
    if (enableFeatures[HESSIAN] && minimumSigma < 2) {
      if (Thread.currentThread().isInterrupted())       return false;
      futures.add(exe.submit(getHessian(originalImage,0)));
    }
    for (float i=minimumSigma; i <= maximumSigma; i*=2) {
      if (Thread.currentThread().isInterrupted())       return false;
      if (enableFeatures[GAUSSIAN]) {
        futures.add(exe.submit(getGaussianBlur(originalImage,i)));
      }
      if (enableFeatures[SOBEL]) {
        futures.add(exe.submit(getGradient(originalImage,i)));
      }
      if (enableFeatures[HESSIAN]) {
        futures.add(exe.submit(getHessian(originalImage,i)));
      }
      if (enableFeatures[DOG]) {
        for (float j=minimumSigma; j < i; j*=2) {
          futures.add(exe.submit(getDoG(originalImage,i,j)));
        }
      }
      if (enableFeatures[VARIANCE]) {
        futures.add(exe.submit(getVariance(originalImage,i)));
      }
      if (enableFeatures[MEAN]) {
        futures.add(exe.submit(getMean(originalImage,i)));
      }
      if (enableFeatures[MINIMUM]) {
        futures.add(exe.submit(getMin(originalImage,i)));
      }
      if (enableFeatures[MAXIMUM]) {
        futures.add(exe.submit(getMax(originalImage,i)));
      }
      if (enableFeatures[MEDIAN]) {
        futures.add(exe.submit(getMedian(originalImage,i)));
      }
      if (enableFeatures[DERIVATIVES]) {
        for (int order=minDerivativeOrder; order <= maxDerivativeOrder; order++)         futures.add(exe.submit(getDerivatives(originalImage,i,order,order)));
      }
      if (enableFeatures[LAPLACIAN]) {
        futures.add(exe.submit(getLaplacian(originalImage,i)));
      }
      if (enableFeatures[STRUCTURE]) {
        for (int integrationScale=1; integrationScale <= 3; integrationScale+=2)         futures.add(exe.submit(getStructure(originalImage,i,integrationScale)));
      }
      if (enableFeatures[ENTROPY]) {
        for (int nBins=32; nBins <= 256; nBins*=2)         futures.add(exe.submit(getEntropy(originalImage,(int)i,nBins)));
      }
    }
    if (enableFeatures[MEMBRANE]) {
      if (Thread.currentThread().isInterrupted())       return false;
      futures.add(exe.submit(getMembraneFeatures(originalImage,membranePatchSize,membraneSize)));
    }
    for (    Future<ImagePlus> f : futures) {
      final ImagePlus res=f.get();
      currentIndex++;
      IJ.showStatus("String_Node_Str");
      IJ.showProgress(currentIndex,finalIndex);
      if (res.getImageStackSize() == 1) {
        this.wholeStack.addSlice(res.getTitle(),res.getProcessor());
      }
 else {
        final ImageStack slices=res.getImageStack();
        for (int i=1; i <= slices.getSize(); i++)         this.wholeStack.addSlice(slices.getSliceLabel(i),slices.getProcessor(i));
      }
    }
  }
 catch (  InterruptedException ie) {
    IJ.log("String_Node_Str");
    return false;
  }
catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
    return false;
  }
 finally {
    exe.shutdownNow();
  }
  IJ.showProgress(1.0);
  IJ.showStatus("String_Node_Str");
  return true;
}