title: forkjoinpool execute non-recursive tasks and join all
body: <p>I have a list of objects stored in an array, each with a simple (non-recursive) task to compute.</p>
  
  <p>I want to execute those method of each object in parallel, then wait for all of them to finish before continuing.</p>
  
  <p>May I know if the code below will do what I want? Are there any problems that I overlook?</p>
  
  <p>Thanks.</p>
  
  <pre><code>public void calculateAllFitnessParallel() 
  {
      ForkJoinPool pool = new ForkJoinPool();
  
      for (int i = 0; i &lt; currentPopulation; i++)
          pool.execute(individuals[i]); // execute these in parallel
  
      // close pool and wait
      pool.shutdown();
      for (int i = 0; i &lt; currentPopulation; i++)
          individuals[i].join();
  
      // need all parallel tasks to finish before this
      findFittest();
  
  }
  </code></pre>