1 #!/usr/bin/python 2 3 from multiprocessing import Process,Queue 4 import time 5 6 l=[] 7 q=Queue() 8 9 def f(name): 10 time.sleep(1) 11 q.put("hello"+str(name)) 12 13 for i in range(10): 14 p=Process(target=f,args=(i,)) 15 p.start() 16 l.append(p) 17 18 for j in l: 19 j.join() 20 for i in range(10): 21 print q.get()