title: spawn multiple threads in loop and knowing when all finished to do certain task
body: <p>I have to spawn multiple threads in loop for configured no. of sites and then each thread has multiple child threads. After finishing all threads I need to do certain task to save data into database. How I come to know whether all task has finished.<br>
  my current code:</p>
  
  <pre><code>List&lt;SocialDataConfig&gt; configList = SetConfiguration();
  foreach (SocialDataConfig config in configList)
  {
      new Thread(delegate()
      {
          FetchSocialData(config);
      }).Start();
  }
  // save fetched data into database and log fetched information in database
  
  private void FetchSocialData(SocialDataConfig config)
  {
      for (int i = 0; i &lt; config.ThreadCount; i++)
      {
          Thread thread = new Thread(delegate()
          {
              FetchData(54764876, config);
          });
          thread.Start();
      }
  }
  </code></pre>