Thread.Join versus Task.Wait
<p>Consider the following code.</p>

<h2>Thread</h2>

<pre><code>static void Main(string[] args)
{
    Thread t = new Thread(Foo);
    t.Start();

    Console.WriteLine("Main ends.");
    //t.Join();
}

static void Foo()
{
    for (int x = 0; x &lt; 1000000000; x++) ;

    Console.WriteLine("Foo ends.");
}
</code></pre>

<h2>Task</h2>

<pre><code>static void Main(string[] args)
{
    Task t = new Task (Foo);
    t.Start();

    Console.WriteLine("Main ends.");
    t.Wait();
}

static void Foo()
{
    for (int x = 0; x &lt; 1000000000; x++) ;

    Console.WriteLine("Foo ends.");
}
</code></pre>

<p>When using <code>Task</code>, we need <code>t.Wait()</code> to wait for the thread pool thread to complete before the main thread ends but when using <code>Thread</code>, we don't need <code>t.Join</code> to get the same effect.</p>

<h1>Question</h1>

<p>Why is <code>t.Join()</code> not needed to prevent the main thread from ending before the other spawned threads end?</p>