public class PipelineTask implements Runnable {
   private Runnable task;
   private int index;
   private ThreadPool array[];

   public PipelineTask(ThreadPool array[], Runnable task) {
      this.task = task;
      this.index = 0;
      this.array = array;
   }

   public void run() {
      task.run();

      index++;

      if(index < array.length)  
         array[index].postTaskForExecution(this);
   }
}

