zoukankan      html  css  js  c++  java
  • [多线程] WaitHandle.WaitAll ManualResetEvent 等待所有线程完成

                Thread[] threads = new Thread[30];
                ManualResetEvent[] events = new ManualResetEvent[10];
                for (int i = 0; i < threads.Length; i++)
                {
                    events[i] = new ManualResetEvent(false);
                    threads[i] = new Thread(worker(events[i]));  // call events[i].Set() when the task is done.
                    threads[i].Start();
                }
                WaitHandle.WaitAll(events);


    或者

                for (int i = 0; i < threads.Length; i++)
                {
                    threads[i].Join();
                }

  • 相关阅读:
    如何判断栈的增长方向
    时间复杂度
    shell基础part3
    shell基础part2
    shell基础part2
    linux基础part5
    linux基础part4
    linux基础part3
    linux基础part2
    shell基础part1
  • 原文地址:https://www.cnblogs.com/webglcn/p/2487568.html
Copyright © 2011-2022 走看看