title: Differences between multithreading and multitasking in C#
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4130194/what-is-the-difference-between-task-and-thread">What is the difference between task and thread?</a>  </p>
  </blockquote>
  
  
  
  <p>I understand the title itself may appear to be a duplicate question but I've really read all the previous posts related to this topic and still don't quite understand the program behavior.</p>
  
  <p>I'm currently writing a small program that checks around 1,000 E-mail accounts. Undoubtedly I feel multithreading or multitasking is the right approach since each thread / task is not computationally expensive but the duration of each thread relies heavily on network I/O.</p>
  
  <p>I think that under such a scenario, it would also be reasonable to set the number of threads / tasks at a number that is much larger than the number of cores. (four for i5-750). Therefore I've set the number of threads or tasks at 100.</p>
  
  <p>The code snippet written using Tasks:</p>
  
  <pre><code>        const int taskCount = 100;
          var tasks = new Task[taskCount];
          var loopVal = (int) Math.Ceiling(1.0*EmailAddress.Count/taskCount);
  
          for (int i = 0; i &lt; taskCount; i++)
          {
              var objContainer = new AutoCheck(i*loopVal, i*loopVal + loopVal);
              tasks[i] = new Task(objContainer.CheckMail);
              tasks[i].Start();
          }
          Task.WaitAll(tasks);
  </code></pre>
  
  <p>The same code snippet written using Threads:</p>
  
  <pre><code>        const int threadCount = 100;
          var threads = new Thread[threadCount];
          var loopVal = (int)Math.Ceiling(1.0 * EmailAddress.Count / threadCount);
  
          for (int i = 0; i &lt; threadCount; i++)
          {
              var objContainer = new AutoCheck(i * loopVal, i * loopVal + loopVal);
              threads[i] = new Thread(objContainer.CheckMail);
              threads[i].Start();
          }
          foreach (Thread t in threads)
              t.Join();
          runningTime.Stop();
          Console.WriteLine(runningTime.Elapsed);
  </code></pre>
  
  <p>So what are the essential differences between these two?</p>