1. 程式人生 > >程序鎖,用在螢幕列印資料時,多程序

程序鎖,用在螢幕列印資料時,多程序


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(100):
Process(target=f, args=(lock, num)).start()