import time from multiprocessing import Process,Pool def Foo(i): time.sleep(1) print(i) def Bar(arg): print('hello') if __name__ == '__main__': pool = Pool(5) #进程池的容量是5 for i in range(100): pool.apply_async(func=Foo,args=(i,),callback=Bar) #callback是回调函数 pool.close() pool.join() print('end---')