python 多进程
#方法一 直接调用
import time
import random
from multiprocessing import Process
def run(name):
index = 0
for i in range(3):
print('%s runing' %name)
time.sleep(random.randrange(1,5))
print('%s running end' %name)
index +1
l = []
if __name__ == "__main__":
for i in range(20):
p = Process(target=run,args=(i,))
p.start()
l.append(p)
for proc in l:
proc.join()
print("执行完毕")