title: How to prevent threads from dying or just quitting in C# .NET?
body: <p>I am starting atmost 5 threads in a program in C# .NET. But sometimes some of those threads just quit or become dead inexplicably even before the completion of execution of the function assigned to it.</p>
  
  <p>It happens randomly . If I try to debug the code by putting breakpoints- It works fine.</p>
  
  <p>And sometimes all the threads execute the assigned functions perfectly.They do not share any resources among them.</p>
  
  <pre><code>            Thread[] td = new Thread[5];
              for (count = 4; count &gt;= 0; --count)
              {
                  ds[count] = dba.getData(ru[count]);
                  td[count] = new Thread(delegate() {  runRule[count].performTask(ru[count], ds[count], count); });
                  td[count].Name = "Thread " + count.ToString();
                  td[count].Start();
                  Thread.Sleep(50);
              }
  </code></pre>
  
  <p>If I remove the last line "Thread.Sleep(50)" only the first thread stared runs and rest of them just die.</p>
  
  <p>can someone explain why the threads are becoming dead?</p>