python aa.py
process id: 632
process id: 635
process id: 637
process id: 633
process id: 636
process id: 634
process id: 639
process id: 638
process id: 641
process id: 640
------------------------
process id: 619
[]
```python import os from multiprocessing import Process, Manager, Lock
lock = Lock() manager = Manager() sum = manager.Value('tmp', 0)
def testFunc(cc, lock): with lock: sum.value += cc
if name == 'main': threads = []
for ll in range(100):
t = Process(target=testFunc, args=(1, lock))
t.daemon = True
threads.append(t)
for i in range(len(threads)):
threads[i].start()
for j in range(len(threads)):
threads[j].join()
print("------------------------")
print('process id:', os.getpid())
print(sum.value)