title: Fork-Join Pool not producing any result whereas the serial codes works optimally
body: <p>The other serial code I wrote works perfectly, but this parallel version is not giving any output, it just prints hello, I am testing it with &quot;hey&quot; it never even gets to that line i.e. it gets stuck on invoke method, I couldn't find any helpful resources online.</p>
  <p>Please help me in understanding where I am going wrong I am new to parallel programming.</p>
  <p>The code is a median filter program, that when given an array x=[2,80,6,3] the filtered array is y=[2,6,6,3] calculated as:</p>
  <blockquote>
  <p>y[1] = Median[2 2 80] = 2</p>
  <p>y[2] = Median[2 80 6] = Median[2 6 80] = 6</p>
  <p>y[3] = Median[80 6 3] = Median[3 6 80] = 6</p>
  <p>y[4] = Median[6 3 3] = Median[3 3 6] = 3</p>
  </blockquote>
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Scanner;
  import java.util.concurrent.ForkJoinPool;
  import java.util.concurrent.RecursiveAction;
  import java.io.PrintWriter;
  
  public class ParallelFilter extends RecursiveAction {
  
  static final int SEQUENTIAL_THRESHOLD=500; 
  ArrayList&lt;Float&gt; inputArray;
  int sizeOfFilter;
  ArrayList&lt;Float&gt; outputlist;
  ArrayList&lt;Float&gt; arrayFiltered;
  
  float high;
  float low;
  
  public ParallelFilter(ArrayList&lt;Float&gt; inputArray,int sizeOfFilter,float           high,float low)
                   {
    
    this.inputArray=inputArray;
     this.outputlist=outputlist;
    this.sizeOfFilter=sizeOfFilter;
    this.arrayFiltered=arrayFiltered;
    //this.index=index;
    this.high=high;
    this.low=low;
   }
  
  
  
  
   protected void compute()
   {
    int index=1;
    
    if((high - low) &lt; SEQUENTIAL_THRESHOLD )
    {
        while(inputArray.size() &gt; sizeOfFilter){
       for(int i=0; i&lt;sizeOfFilter;i++){
          
           arrayFiltered.add(i,inputArray.get(i));
           
       }
       
           Collections.sort(arrayFiltered);
           float median = arrayFiltered.get(arrayFiltered.size()/2);
           outputlist.add(index,median);
           inputArray.remove(inputArray.get(0));
           arrayFiltered.clear();
           index=index+1;
        
        }
        
        outputlist.add(inputArray.get(inputArray.size()-1));
    }
    
    
      else{
        
        ParallelFilter leftTask = new       ParallelFilter(inputArray,sizeOfFilter,low,(low+high)/2);
        ParallelFilter rightTask = new ParallelFilter(inputArray,sizeOfFilter,(low+high)/2,high);
        leftTask.fork();
        rightTask.compute();
        leftTask.join();
    }
    
    }
  
  
  
     public static void main(String[] args){
    
    try
    {
        Scanner sc;
        sc = new Scanner(new File(&quot;inp1.txt&quot;));
        sc.useDelimiter(&quot; &quot;);
        ArrayList&lt;Float&gt; inputlist = new ArrayList&lt;&gt;();
        
        //POPULATE LIST FROM FILE
        while (sc.hasNextLine()) {
            
        if(sc.nextLine().length() == 1){continue;}
        String[] parts = sc.nextLine().split(&quot; &quot;); // split each line by &quot; &quot;
   
        inputlist.add(Float.parseFloat(parts[1]))  ; 
        // System.out.println(parts[1]);
                             }
      
        System.out.println(&quot;Enter filter size : &quot;);
        Scanner in = new Scanner(System.in);
        int sizeOfFilter = in.nextInt();
        if (sizeOfFilter &lt; 3 || sizeOfFilter / 2 == 0) {
               System.out.println(&quot;Filter size should be odd and bigger than 3&quot;);
           }
        
        float low = inputlist.get(0);
        float high = inputlist.get(inputlist.size()-1);
        
        ParallelFilter pf = new ParallelFilter(inputlist,sizeOfFilter,low,high);
        System.out.println(&quot;hello&quot;);
        ForkJoinPool forkJoinPool = new ForkJoinPool();
        forkJoinPool.invoke(pf);//suspect the problem is here...
        
        for (int i=0; i&lt;pf.outputlist.size();i++){
            
        System.out.println(pf.outputlist.get(i));}
        System.out.println(&quot;hey&quot;);
        
      }
    catch(Exception e){}
    
   }
  
  
  
    }
  </code></pre>