# -*- coding: utf-8 -*- ''' 进程锁主要防止在屏幕打印的时候数据会乱 ''' from multiprocessing import Process,Lock def f(l,i): l.acquire() print('hello :',i) l.release() if __name__=='__main__': lock = Lock() for num in range(10): Process(target=f,args=(lock,num)).start()