zoukankan      html  css  js  c++  java
  • 多线程13-CountdownEvent

        class Program
        {
            static CountdownEvent _countdownEvent = new CountdownEvent(2);
            static void PerformOperation(string message,int second)
            {
                Thread.Sleep(TimeSpan.FromSeconds(second));
                Console.WriteLine(message);
                _countdownEvent.Signal();
            }
            static void Main()
            {
                Console.WriteLine("Starting two operations");
                var t1 = new Thread(() => PerformOperation("Opearation1 is completed"4));
                var t2 = new Thread(() => PerformOperation("Opeartion2 is compled"2));
                t1.Start();
                t2.Start();
                _countdownEvent.Wait();
                Console.WriteLine("Both operations have been compled");
                _countdownEvent.Dispose();
            }
        }
  • 相关阅读:
    禁止网页后退
    C# 数组排序
    SQL求往年的工资和
    手机的隐秘功能
    C#中的String类
    C#修饰符
    Application,Session,Cookie,ViewState和Cache区别
    css margin和padding的区别
    php常见的js正则表达式
    js 正则表达式基础篇
  • 原文地址:https://www.cnblogs.com/shidengyun/p/5606905.html
Copyright © 2011-2022 走看看