多线程初始

static void Main(string[] arg)
{

//创建一个含10个线程的对象数组
Thread[] thread = new Thread[2];
for (int i = 0; i < thread.Length; i++)
{
//将每个线程都指向Go方法
thread[i] = new Thread(new ThreadStart(Go));
//将每个线程命名
thread[i].Name = (i + 1).ToString() + "号线程";
}
foreach (Thread item in thread)
{
item.Start();
}
Console.ReadLine();
}

public static void Go()
{
Console.WriteLine("--->{0},正在执行Go打印方法", Thread.CurrentThread.Name);
Console.WriteLine("打印的数字为:");
for (int i = 0; i < 10; i++)
{
Console.Write(i);
Thread.Sleep(2000);
}
Console.WriteLine();
}

原文地址:https://www.cnblogs.com/become/p/4905342.html