Python多线程中阻塞(join)与锁(Lock)的使用误区

Posted 我和你并没有不同

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python多线程中阻塞(join)与锁(Lock)的使用误区相关的知识,希望对你有一定的参考价值。

参考资料:https://blog.csdn.net/cd_xuyue/article/details/52052893

1使用两个循环分别处理startjoin函数.即可实现并发.

threads = [Thread() for i in range(5)]
for thread in threads:
    thread.start()
for thread in threads:
    thread.join()

  2 要保证锁对于多个子线程来说是共用的,即不要在Thread的子类内部创建锁.

以上是关于Python多线程中阻塞(join)与锁(Lock)的使用误区的主要内容,如果未能解决你的问题,请参考以下文章