【问题标题】:How to block the main thread until all the other threads finish executing?如何阻塞主线程直到所有其他线程完成执行?
【发布时间】:2011-06-03 12:43:21
【问题描述】:

这是一个新手问题。我从我的主线程开始 10 个线程。如何阻止主线程继续运行,直到所有其他线程完成?

【问题讨论】:

    标签: python


    【解决方案1】:

    Join所有线程:

    for t in threads:
        t.join()
    

    这里threads 是您的线程列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多