进程锁其实是锁的输入终端,屏幕,太多的进程,为了防止打印错乱而锁,作用不大
from multiprocessing import Process, Lock def f(l, i): l.acquire() print('hello world', i) l.release() if __name__ == '__main__': lock = Lock() for num in range(10): Process(target=f, args=(lock, num)).start()
...