在进程中创建的第一个线程称为主线程。它首先开始,最后结束。
让我们看一个 C# 中的主线程示例。
using System;
using System.Threading;
public class ThreadExample
{
public static void Main(string[] args)
{
Thread t = Thread.CurrentThread;
t.Name = "主线程";
Console.WriteLine(t.Name);
}
}
输出:
主线程
