class="brush:csharp;gutter:false;"> class Program
    {
      static  AutoResetEvent are = new AutoResetEvent(false);
      static int ticks = 100;
        static void Main(string[] args)
        {
            Thread t1 = new Thread(new ThreadStart(Saling));
            Thread t2 = new Thread(new ThreadStart(Saling));
            Thread t3 = new Thread(new ThreadStart(Saling));
            Thread t4 = new Thread(new ThreadStart(Saling));
            t1.Name = "1";
            t2.Name = "2";
            t3.Name = "3";
            t4.Name = "4";
            t1.Start();
            t2.Start();
            t3.Start();
            t4.Start();
            Console.ReadKey();
        }
        public static void Saling()
        {
            Thread th = Thread.CurrentThread; //得到当前线程
            while(ticks>-1)
            {
                Console.WriteLine("ThreadName:"+th.Name+" 票数:"+ticks--);
                are.Set();//终止当前线程,让下一个线程来执行
                Thread.Sleep(50);
            }
        }
    }