摘要: 方式:队列(推荐使用) 一、基本情况 1.可以往队列里放任意类型的数据 2. 队列:先进先出 3. q=Queue(3) #可以设置队列中最多可以进入多少个值,也可以不设置 q.put('first') q.put('second') q.put('third') # q.put('fourht') 阅读全文
posted @ 2017-08-25 17:02 Cool· 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 1 from multiprocessing import Process 2 import os 3 import time 4 def work(): 5 print('%s is working' %os.getpid()) 6 time.sleep(3) 7 if __name__ == ' 阅读全文
posted @ 2017-08-25 16:24 Cool· 阅读(2052) 评论(0) 推荐(0) 编辑
摘要: 1 from multiprocessing import Process,Lock 2 import os 3 import time 4 def work(mutex): 5 mutex.acquire() 6 print('task[%s] 上厕所' %os.getpid()) 7 time. 阅读全文
posted @ 2017-08-25 16:04 Cool· 阅读(188) 评论(0) 推荐(0) 编辑