Program: 58010
Project: 58010
Buggy source:
@Override public void run(){
  final long start=System.currentTimeMillis();
  while ((System.currentTimeMillis() - start) < 20) {
    if (chunks.size() == 0) {
      TaskManager.runTaskLater(whenDone,1);
      Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
      TaskManager.tasks.remove(currentIndex);
      return;
    }
    CURRENT_PLOT_CLEAR=new RegionWrapper(pos1.getX(),pos2.getX(),pos1.getZ(),pos2.getZ());
    final Chunk chunk=chunks.get(0);
    chunks.remove(0);
    final int x=chunk.getX();
    final int z=chunk.getZ();
    boolean loaded=true;
    if (!chunk.isLoaded()) {
      final boolean result=chunk.load(false);
      if (!result) {
        loaded=false;
      }
      if (!chunk.isLoaded()) {
        loaded=false;
      }
    }
    if (loaded) {
      initMaps();
      final int absX=x << 4;
      final int absZ=z << 4;
      boolean save=false;
      if ((x == c1x) || (z == c1z)) {
        save=true;
        for (int X=0; X < 16; X++) {
          for (int Z=0; Z < 16; Z++) {
            if ((((X + absX) < sx) || ((Z + absZ) < sz)) || (((X + absX) > ex) || ((Z + absZ) > ez))) {
              saveBlocks(world,maxY,X + absX,Z + absZ);
            }
          }
        }
      }
 else       if ((x == c2x) || (z == c2z)) {
        for (int X=0; X < 16; X++) {
          save=true;
          for (int Z=0; Z < 16; Z++) {
            if ((((X + absX) > ex) || ((Z + absZ) > ez)) || (((X + absX) < sx) || ((Z + absZ) < sz))) {
              saveBlocks(world,maxY,X + absX,Z + absZ);
            }
          }
        }
      }
      if (save) {
        saveEntitiesOut(chunk,CURRENT_PLOT_CLEAR);
      }
      ChunkLoc loc=new ChunkLoc(chunk.getX(),chunk.getZ());
      regenerateChunk(world.getName(),loc);
      if (save) {
        restoreBlocks(world,0,0);
        restoreEntities(world,0,0);
      }
      MainUtil.update(world.getName(),loc);
      BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[]{chunk}));
    }
    CURRENT_PLOT_CLEAR=null;
  }
}

Fixed version (ground truth):
@Override public void run(){
  long start=System.currentTimeMillis();
  while (chunks.size() > 0 && System.currentTimeMillis() - start < 50) {
    ChunkLoc chunk=chunks.remove(0);
    int x=chunk.x;
    int z=chunk.z;
    int xxb=x << 4;
    int zzb=z << 4;
    int xxt=xxb + 15;
    int zzt=zzb + 15;
    CURRENT_PLOT_CLEAR=null;
    Chunk chunkObj=worldObj.getChunkAt(x,z);
    if (!chunkObj.load(false)) {
      System.out.print("String_Node_Str" + x + "String_Node_Str"+ z);
      continue;
    }
    CURRENT_PLOT_CLEAR=new RegionWrapper(pos1.getX(),pos2.getX(),pos1.getZ(),pos2.getZ());
    if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
      if (canRegen && ap != null) {
        ap.populate(worldObj,null,chunkObj);
      }
 else {
        regenerateChunk(world,chunk);
      }
      continue;
    }
    boolean checkX1=false;
    boolean checkX2=false;
    boolean checkZ1=false;
    boolean checkZ2=false;
    int xxb2;
    int zzb2;
    int xxt2;
    int zzt2;
    if (x == bcx) {
      xxb2=p1x - 1;
      checkX1=true;
    }
 else {
      xxb2=xxb;
    }
    if (x == tcx) {
      xxt2=p2x + 1;
      checkX2=true;
    }
 else {
      xxt2=xxt;
    }
    if (z == bcz) {
      zzb2=p1z - 1;
      checkZ1=true;
    }
 else {
      zzb2=zzb;
    }
    if (z == tcz) {
      zzt2=p2z + 1;
      checkZ2=true;
    }
 else {
      zzt2=zzt;
    }
    initMaps();
    if (checkX1) {
      saveRegion(worldObj,xxb,xxb2,zzb2,zzt2);
    }
    if (checkX2) {
      saveRegion(worldObj,xxt2,xxt,zzb2,zzt2);
    }
    if (checkZ1) {
      saveRegion(worldObj,xxb2,xxt2,zzb,zzb2);
    }
    if (checkZ2) {
      saveRegion(worldObj,xxb2,xxt2,zzt2,zzt);
    }
    if (checkX1 && checkZ1) {
      saveRegion(worldObj,xxb,xxb2,zzb,zzb2);
    }
    if (checkX2 && checkZ1) {
      System.out.print("String_Node_Str");
      System.out.print(xxt2 + ',' + xxt+ "String_Node_Str"+ zzb+ "String_Node_Str"+ zzb2);
      saveRegion(worldObj,xxt2,xxt,zzb,zzb2);
    }
    if (checkX1 && checkZ2) {
      System.out.print("String_Node_Str");
      System.out.print(xxb + ',' + xxb2+ "String_Node_Str"+ zzt2+ "String_Node_Str"+ zzt);
      saveRegion(worldObj,xxb,xxb2,zzt2,zzt);
    }
    if (checkX2 && checkZ2) {
      saveRegion(worldObj,xxt2,xxt,zzt2,zzt);
    }
    saveEntitiesOut(chunkObj,CURRENT_PLOT_CLEAR);
    if (canRegen && ap != null) {
      ap.populate(worldObj,null,chunkObj);
    }
 else {
      regenerateChunk(world,chunk);
    }
    restoreBlocks(worldObj,0,0);
    restoreEntities(worldObj,0,0);
  }
  CURRENT_PLOT_CLEAR=null;
  if (chunks.size() != 0) {
    TaskManager.runTaskLater(this,1);
  }
 else {
    TaskManager.runTaskLater(whenDone,1);
  }
}