title: When does a multithreaded console application exit?
body: <pre><code>class Program
  {
      public static void Main(String[] args)
      {
          var c = new C();
          var thread = new Thread(new ThreadStart(c.F));
          thread.Start();
          Console.WriteLine("Exiting main, but the program won't quit yet...");
      }
  }
  class C
  {
      public void F()
      {
          for (int i = 0; i &lt; 10; i++)
          {
              Console.WriteLine("Waiting {0}", i);
              Thread.Sleep(1000);
          }
          Console.WriteLine("Now the program will quit...");
      }
  }
  </code></pre>
  
  <p>What's going on under the hood with a console application that leads to it waiting for the other thread to finish before exiting (pointer to docs fine)?</p>
  
  <p><em>Note: I know this is a basic question - I just always managed waiting for threads to finish before and never considered there was some infrastructure that did it for me...</em></p>