title: Threads that return data in .NET
body: <p>I'm writing a program where I typically start five threads. The threads return in a non-determinate order. Each thread is calling a method which returns a List.</p>
  
  <p>I'm doing this:</p>
  
  <pre><code>var masterList = List&lt;string&gt;();    
  foreach (var threadParam in threadParams)
  {
      var expression = threadParam ;
      ThreadStart sub = () =&gt; MyMethod(expressions);
      var thread = new Thread(sub)
      {
          Name = expression
      };
  
      listThreads.Add(thread);
      thread.Start();
  }
  
  var abort = true;
  while (abort) //Wait until all threads finish
  {
      var count = 0;
      foreach (var list in listThreads)
      {
          if (!list.IsAlive)
          {
              count++;
          }
      }
  
      if (count == listThreads.Count)
      {
          abort = false;
      }
  }
  </code></pre>
  
  <p>So here is the problem:</p>
  
  <p>Each thread when it terminates returns a list I would like to append the masterList declared earlier.</p>
  
  <p>How would one go about this?</p>
  
  <p>Also I KNOW there must be a better way than below to wait for all threads to finish</p>
  
  <pre><code>var abort = true;
  while (abort) //Wait until all threads finish
  {
      var count = 0;
      foreach (var list in listThreads)
      {
          if (!list.IsAlive)
          {
              count++;
          }
      }
  
      if (count == listThreads.Count)
      {
          abort = false;
      }
  }
  </code></pre>