标签:roc targe imp 同步锁 port span int target ssi
# 进程的同步 (类似于线程的同步锁,同一时刻只能一个进程运行) from multiprocessing import Process, Lock import time def f(l, i): with l: time.sleep(1) print(‘helloworld %s‘ % i) # 上面with l: 相当于 # l.acquire() # print(‘helloworld %s‘ % i) # l.release() if __name__ == ‘__main__‘: lock = Lock() for num in range(10): Process(target=f, args=(lock, num,)).start()
标签:roc targe imp 同步锁 port span int target ssi
原文地址:https://www.cnblogs.com/dangrui0725/p/9499357.html