using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            ////线程方法1
            //if (ThreadPool.QueueUserWorkItem(new WaitCallback(Program.WritePara), "这是传进去的参数"))
            //{
            //    Console.WriteLine("ok:");
            //    Console.Read();
            //}
            //线程方法2
            Thread th = new Thread(new ThreadStart(Write));
            th.Start();
            //线程方法3
            Thread thread = new Thread(new ParameterizedThreadStart(WritePara));
            thread.Start("Thread thread = new Thread( new ParameterizedThreadStart(WritePara))有参传递");


        }
        protected static void WritePara(object para)
        {
            Console.WriteLine("hello:" + para);
        }

        private static void Write()
        {
            Console.WriteLine(" Thread th = new Thread(new ThreadStart(Write));无参线程调用");
        }
    }
}

相关文章:

  • 2021-10-29
  • 2021-05-20
  • 2021-06-10
  • 2021-06-05
  • 2022-12-23
  • 2021-08-23
  • 2021-10-20
  • 2021-10-03
猜你喜欢
  • 2022-12-23
  • 2022-02-24
  • 2021-12-16
  • 2022-12-23
相关资源
相似解决方案