title: generate new threads dynamically using C# .NET
body: <p>How can I generate a thread dynamically in an efficient and controlled manner? The threads are to be created dynamically based on each XML host id.</p>
  
  <p>Example:</p>
  
  <pre><code>samplethread1  for hostid:-1
  samplethread2  for hostid:-2
  </code></pre>
  
  <p>Because I cannot rely on the host id count I need to make my code dynamic: suggest how I can have a control on each thread. </p>
  
  <p>Given a piece of sample XML code:</p>
  
  <pre><code>&lt;?xml version="1.0" standalone="yes"?&gt;
    &lt;HOSTS&gt;
       &lt;Host id = '1'&gt;
         &lt;Extension&gt;txt&lt;/Extension&gt;
         &lt;FolderPath&gt;C:/temp&lt;/FolderPath&gt;
       &lt;/Host&gt;
       &lt;Host id = '2'&gt;
         &lt;Extension&gt;rar&lt;/Extension&gt;
         &lt;FolderPath&gt;C:/Sample&lt;/FolderPath&gt;
       &lt;/Host&gt;
    &lt;/HOSTS&gt;
  </code></pre>