from multiprocessing import Process,Manager,Lock def func(dic,lock): lock.acquire() dic["count"] -= 1 lock.release() if __name__ == '__main__': m = Manager() dic = m.dict({"count":100}) p_lst = [] lock = Lock() for i in range(20): p = Process(target=func,args=(dic,lock)) p.start() p_lst.append(p) for p in p_lst:p.join() print("主进程:",dic)