在线程里再创建一个线程,这就是父子线程
父线程的结束并不影响子线程
因为在进程层面里,大家都是平级的
static void Method2()
{
System.Threading.Thread.Sleep(5000);
Console.Write("子线程结束");
}
static void Method1()
{
//System.Threading.ThreadPool.QueueUserWorkItem(Method2 );
new Thread(new System.Threading.ThreadStart(Method2)).Start ();
System.Threading.Thread.Sleep(1000);
Console.Write("父线程结束");
}
static void Main(string[] args)
{
new Thread(new System.Threading.ThreadStart(Method1)).Start ();
Console.ReadLine();
}
结果是 父线程先结束,子线程再结束
负责创建的,并不是要负责销毁