Possible Duplicate:
What is the difference between task and thread?
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.
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.
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.
The code snippet written using Tasks:
const int taskCount = 100;
var tasks = new Task[taskCount];
var loopVal = (int) Math.Ceiling(1.0*EmailAddress.Count/taskCount);
for (int i = 0; i < taskCount; i++)
{
var objContainer = new AutoCheck(i*loopVal, i*loopVal + loopVal);
tasks[i] = new Task(objContainer.CheckMail);
tasks[i].Start();
}
Task.WaitAll(tasks);
The same code snippet written using Threads:
const int threadCount = 100;
var threads = new Thread[threadCount];
var loopVal = (int)Math.Ceiling(1.0 * EmailAddress.Count / threadCount);
for (int i = 0; i < 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);
So what are the essential differences between these two?