static void Main()
{
AutoResetEvent autoEvent = new AutoResetEvent(false);
Thread regularThread =
new Thread(new ThreadStart(ThreadMethod));
regularThread.IsBackground = true;
regularThread.Start();
regularThread.Join();//注释掉join将不输出数字;等待regularThread执行完毕再继续主线程
Console.WriteLine("end");
}
static void ThreadMethod()
{
for (int i = 0; i < 10; ++i)
{
Thread.Sleep(100);
Console.WriteLine(i.ToString());
}
}