美文网首页
threading模块中join()和setDaemon()

threading模块中join()和setDaemon()

作者: 蒋狗 | 来源:发表于2017-02-07 21:48 被阅读0次

    setDaemon():将该线程声明为守护线程setDaemon(True),子线程会随着父线程的终止而终止;否则,子线程仍在运行中,主线程不会退出(但会向后执行),直到所有子线程运行结束。setDaemon()需要在start()前声明。

    join(timeout):阻塞主线程,等待子线程结束,专注执行多线程,timeout为设置阻塞的超时时间。


    demo.png

    相关文章

      网友评论

          本文标题:threading模块中join()和setDaemon()

          本文链接:https://www.haomeiwen.com/subject/vlzuittx.html