class Program
    {
        static ManualResetEventSlim manualRestEvnetSlim = new ManualResetEventSlim(false);
        static void TravelThroughGates(string threadName,int second)
        {
            Console.WriteLine("{0} falls to sleep", threadName);
            Thread.Sleep(TimeSpan.FromSeconds(second));
            Console.WriteLine("{0} waits for the gate open", threadName);
            manualRestEvnetSlim.Wait();
            Console.WriteLine("{0} enter the gates", threadName);
        }         static void Main()
        {
            var t1 = new Thread(() => TravelThroughGates("T1", ));
            var t2 = new Thread(() => TravelThroughGates("T2", ));
            var t3 = new Thread(() => TravelThroughGates("T3", ));
            t1.Start();
            t2.Start();
            t3.Start();
            Thread.Sleep(TimeSpan.FromSeconds());
            Console.WriteLine("the Gates is open");
            manualRestEvnetSlim.Set();
            Thread.Sleep(TimeSpan.FromSeconds());
            manualRestEvnetSlim.Reset();
            Console.WriteLine("the gate has been closed");
            Thread.Sleep(TimeSpan.FromSeconds());
            Console.WriteLine("the gates opend second times");
            manualRestEvnetSlim.Set();
            Thread.Sleep(TimeSpan.FromSeconds());
            Console.WriteLine("the gates closed angin");
            manualRestEvnetSlim.Reset();         }
    }

最新文章

  1. 【VC++技术杂谈007】使用GDI+进行图片格式转换
  2. Lua 学习笔记(八)错误(error)
  3. linux和windows下的自动ftp脚本(shell bat)
  4. 关于闭包的理解(JS学习小结)
  5. css大牛的博客
  6. PHP 7 值得期待的新特性(上)
  7. GotFocus和PreviewLeftButtonDown事件
  8. Codeforces2B - The least round way(DP)
  9. MyEclipse8.5注册码生成
  10. 操作系统层面聊聊BIO,NIO和AIO (epoll)
  11. k8s 安装步骤
  12. 【vue】如何在 Vue-cli 创建的项目中引入 iView
  13. this 关键字 详解
  14. java提供类与cglib包实现动态代理
  15. div+css ie6图片之间有间隙的问题
  16. http中的get和post的区别
  17. JMeter连接数据库(查询出的数据作为参数)
  18. bash登录过程 其实还不太了解,先码后看
  19. 【题解】洛谷P1073 [NOIP2009TG] 最优贸易(SPFA+分层图)
  20. [css]margin-top重叠

热门文章

  1. ubuntu不能登陆
  2. VMware使用自带工具vmware-vdiskmanager精简占用磁盘空间
  3. DevExpress ASP.NET Core Controls 2019发展蓝图(No.6)
  4. 【bzoj4552】【Tjoi2016&Heoi2016】【NOIP2016模拟7.12】排序
  5. git clone项目失败,Host key verification failed.
  6. JSON提取器
  7. 51nod1820 长城之旅
  8. C#项目类型分三种,Dos(控制台),c/s(客户端与服务器),b/s(浏览器/服务器)
  9. Linux 安装R包
  10. 手写Tomcat源码