zoukankan      html  css  js  c++  java
  • 多线程14-Barrier

    class Program
        {
            static Barrier barrier = new Barrier(2, b => Console.WriteLine("End of phase {0}", b.CurrentPhaseNumber + 1));
            static void PalyMusic(string name, string message, int second)
            {
                for (var i = 1; i <= 3; i++)
                {
                    Console.WriteLine("----------------------------------");
                    Thread.Sleep(TimeSpan.FromSeconds(second));
                    Console.WriteLine("{0} Start to {1}", name, message);
                    Thread.Sleep(TimeSpan.FromSeconds(second));
                    Console.WriteLine("{0} finisheds to {1}", name, message);
                    barrier.SignalAndWait();
                }
            }
            static void Main()
            {
                var t1 = new Thread(() => PalyMusic("the guitarist""paly an amzaing solo"5));
                var t2 = new Thread(() => PalyMusic("the singer""sing his song"2));
                t1.Start();
                t2.Start();
            }
        }
  • 相关阅读:
    严格模式
    es6模块与 commonJS规范的区别
    Javascript内置对象、原生对象、宿主对象关系
    实现继承的几种方式
    创建对象的一些方式
    null的小扩展
    getElementById的缩略
    你真的知道为什么不推荐使用@import?
    换行与不换行
    transition与animation
  • 原文地址:https://www.cnblogs.com/shidengyun/p/5607034.html
Copyright © 2011-2022 走看看