Windows 7, Intel CORE i3, 64 bit, RAM 4Gb, 2.27 GHz
.NET Framework 4.0
I have the following code:
static void Main(string[] args)
{
var timer = new Stopwatch();
timer.Start();
for (int i = 0; i < 0xFFF; ++i)
{
// I use one of the following line at time
Task.Factory.StartNew(() => { });
new Thread(() => { }).Start();
}
timer.Stop();
Console.WriteLine(timer.Elapsed.TotalSeconds);
Console.ReadLine();
}
If I use Task the output is always less then 0.01 seconds, but if I use Thread the output is always greater than 40 seconds!
How is it possible? Why so much difference?