描述:

在 c# 中,system.threading.thread 类用于线程的工作。它允许创建并访问多线程应用程序中的单个线程。进程中第一个被执行的线程称为主线程。

案例:

static void main(string[] args)
{
int num = 100;
for (int i = 0; i < num; i++)
{
//无参的多线程
noparmathread();

}
}
private static void startthread()

{
console.writeline(“——开始了新线程——“);
thread.sleep(2000);//wait
console.writeline(“——线程结束——“);
}

/// <summary>
///不需要传递参数
/// </summary>
private static void noparmathread()
{
threadstart threadstart = new threadstart(startthread);
var thread = new thread(threadstart);
thread.start();//开始线程
}