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的子类内部创建锁.

posted on 2018-06-07 22:05  我和你并没有不同  阅读(1023)  评论(0编辑  收藏  举报