在进程内创建的第一个线程称为主线程。它先开始,最后结束。
让无涯教程看一个用C#编写的主线程示例。
链接:https://www.learnfk.comhttps://www.learnfk.com/csharp/c-sharp-main-thread.html
来源:LearnFk无涯教程网
using System; using System.Threading; public class ThreadExample { public static void Main(string[] args) { Thread t = Thread.CurrentThread; t.Name = "MainThread"; Console.WriteLine(t.Name); } }
输出:
MainThread
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)