子线程的Abort() 为什么会影响主线程的运行?
子线程的Abort() 为什么会影响主线程的运行?
static void Main(string[] args)
{
Thread t = new Thread(MainThreadWork);
t.Start();
Console.WriteLine("Main Start");
Thread.Sleep(1000);
t.Abort();
Console.WriteLine("Main Abort");
Console.ReadLine();
return;
}
static void MainThreadWork()
{
Thread t = new Thread(ChildThreadWork);
t.Start();
Thread.Sleep(1000);
t.Abort();
Console.WriteLine("Main Thread Work");
}
static void ChildThreadWork()
{
Console.WriteLine("Child Thread Work");
}
结果Console.WriteLine("Main Thread Work"); 不会运行 这是为什么?