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());
        }
    }

相关文章:

  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2021-09-21
  • 2021-10-21
  • 2021-12-05
  • 2021-12-22
猜你喜欢
  • 2021-07-03
  • 2022-02-09
  • 2022-12-23
  • 2021-11-07
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案