实现方式
1.引入模块
2.实例Process()
3.start()
4.join()
Demo
import os
from multiprocessing import Process
def run(name):
print 'Child process %s(%s) Running...' % (name,os.getpid())
if __name__ == '__main__':
print 'parent process %s.' % os.getpid()
for i in range(10):
p = Process(target=run, args=(str(i),))
print 'Process will start...'
p.start()
p.join()
print 'Process end.'
网友评论