标签:线程 __name__ release sleep ESS rgs targe multi import
import time
import threading
import multiprocessing
lock = multiprocessing.RLock()
def task(arg):
print('进程来了')
lock.acquire()
time.sleep(2)
print(arg)
lock.release()
if __name__ == '__main__':
p1 = multiprocessing.Process(target=task,args=(1,))
p1.start()
p2 = multiprocessing.Process(target=task, args=(2,))
p2.start()
和线程锁一样,对照线程锁学习即可
标签:线程 __name__ release sleep ESS rgs targe multi import
原文地址:https://www.cnblogs.com/apollo1616/p/10351478.html