|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 dwjgwsm 于 2017-12-20 10:02 编辑
windows7下 wing和pycharm下都试过
from multiprocessing import Process, Queue
def fun(q):
for i in range(5):
print ('put%d'%i)
q.put(i)
#print ('put%d'%i)
while not q.empty():
print ('get=%d size=%d'%(q.get(),q.qsize()))
if __name__=='__main__':
q = Queue()
pw = Process(target=fun, args=(q,))
pw.start()
pw.join()
反复多运行几遍, 运行结果,有时是这样:
put0
put1
put2
put3
put4
get=0 size=4
get=1 size=3
get=2 size=2
get=3 size=1
get=4 size=0
有时是这样:
put0
put1
put2
put3
put4
有时是这样:
put0
put1
put2
put3
put4
get=0 size=4
请问是什么原因?
|
|