摘要: 所以join的作用是保证当前线程执行完成后,再执行其它线程。join可以有timeout参数,表示阻塞其它线程timeout秒后,不再阻塞。详见官方文档。 阅读全文
posted @ 2016-04-21 22:10 dreamfor 阅读(9258) 评论(1) 推荐(1) 编辑
摘要: 1 import threading 2 import time 3 num=0 4 def Mylock(lock): 5 global num 6 lock.acquire() 7 num=num+1 8 time.sleep(1) 9 print num, 10 lock.release() 11 lock=threadin... 阅读全文
posted @ 2016-04-21 21:57 dreamfor 阅读(321) 评论(0) 推荐(0) 编辑
摘要: 先看一个很简单的例子 如果需要一个无限长或者先进后出的队列 关于是否阻塞和timeout的问题 官方文档: Remove and return an item from the queue. If optional args block is true and timeout is None (th 阅读全文
posted @ 2016-04-21 17:17 dreamfor 阅读(3843) 评论(0) 推荐(1) 编辑