参考 https://zhuanlan.zhihu.com/p/410731610
方法1:
#!/usr/bin/python # -*- coding: UTF-8 -*- from multiprocessing import Process import time import os def test_proc(num): for i in range(num): print('子进程运行中,i=%d, name=%s, pid=%d' %(i, __name__, os.getpid())) time.sleep(1) if __name__=='__main__': p1 = Process(target = test_proc, name = 'test1', args=( 10, )) p2 = Process(target = test_proc, name = 'test2', args=( 10, )) p1.start() p2.start() p1.join() p2.join()
方法2:
标签:__,p1,name,创建,test,进程,import,proc,multiprocessing From: https://www.cnblogs.com/ho966/p/17839663.html