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 < 10; i++)
{
Console.WriteLine("Waiting {0}", i);
Thread.Sleep(1000);
}
Console.WriteLine("Now the program will quit...");
}
}
控制台应用程序在底层发生什么导致它等待其他线程完成才退出(文档指针可以)?
注意:我知道这是一个基本问题-我总是成功地等待线程完成,从未考虑过有一些基础设施为我完成它...