摘要: from multiprocessing import Process,Manager,Lock def func(dic,lock): lock.acquire() dic["count"] -= 1 lock.release() if __name__ == '__main__': m = Ma 阅读全文
posted @ 2018-12-15 18:19 superniao 阅读(150) 评论(0) 推荐(0) 编辑
摘要: import time import random from multiprocessing import Process,Queue def producer(q,name,food): for i in range(4): time.sleep(random.random()) f = "{}生 阅读全文
posted @ 2018-12-15 13:52 superniao 阅读(207) 评论(0) 推荐(0) 编辑
摘要: import time,json from multiprocessing import Process,Lock def show(i): with open("ticket") as f: dic = json.load(f) print("余票:{}".format(dic["ticket"])) time.sleep(0.1) ... 阅读全文
posted @ 2018-12-15 13:51 superniao 阅读(318) 评论(0) 推荐(0) 编辑
摘要: import time,random from multiprocessing import Process,Semaphore def ktv(i,sem): sem.acquire() print("{} come in horse".format(i)) time.sleep(random.randint(1,5)) print("{} go out hor... 阅读全文
posted @ 2018-12-15 13:50 superniao 阅读(238) 评论(0) 推荐(0) 编辑