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();
            }
        }
  • 相关阅读:
    readystatechange事件
    DOMContentLoaded事件
    beforeunload事件
    jieba
    模型评估
    机器学习术语
    决策树
    kafka
    即时通讯好文
    HTTP头的Expires与Cache-control
  • 原文地址:https://www.cnblogs.com/shidengyun/p/5607034.html
Copyright © 2011-2022 走看看