C#中的主线程与子线程
主线程
在进程中执行的第一个线程称为主线程。当C#程序开始执行时,将自动创建主线程。
子线程
使用Thread类创建的线程称为主线程的子线程。
这是显示如何创建主线程和子线程的示例-
示例
using System;
using System.Threading;
namespace Demo {
class Program {
static void Main(string[] args) {
Thread th = Thread.CurrentThread;
th.Name = "MainThread";
Console.WriteLine("This is {0}", th.Name);
Console.ReadKey();
}
}
}输出结果
This is MainThread
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短