title: Fork/Join Parallel Patterns
body: <p>Always been a tad weak around with threads and just going through <a href="http://www.microsoft.com/download/en/details.aspx?id=19222" rel="nofollow">Steven Toub's Parallel Computing</a> book.</p>
  
  <p>On Page 39 there are examples of Fork/Join patterns below</p>
  
  <pre><code>static T[] MyParallelInvoke&lt;T&gt;(params Func&lt;T&gt;[] functions)
  {
    T[] results = new T[functions.Length];
    Parallel.For(0, functions.Length, i =&gt;
    {
       results[i] = functions[i]();
    });
    return results;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>// Approach #4: Using PLINQ
  static T[] MyParallelInvoke&lt;T&gt;(params Func&lt;T&gt;[] functions)
  {
    return functions.AsParallel().Select(f =&gt; f()).ToArray();
  }
  </code></pre>
  
  <p>For Approach 3 for example above just to clarify do the results all offically have values,
  when you do </p>
  
  <p>"return results"?</p>
  
  <p>Or will only some of them have values depending on if the Thread has been completed or not?</p>
  
  <p>Similarly for Approach 4 when you call <code>ToArray()</code></p>