首页 > 编程语言 > 详细

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

时间:2018-06-07 22:27:14      阅读:201      评论:0      收藏:0      [点我收藏+]

参考资料: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)的使用误区

原文:https://www.cnblogs.com/testzcy/p/9153048.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!