赞
踩
一般情况下多进程和多线程可以一起使用
import multiprocessing import threading def foo(): print 'threading.current_thread(): ', threading.current_thread() def bar(): threads = [] for _ in range(4): # each Process creates a number of new Threads thread = threading.Thread(target=foo) threads.append(thread) for thread in threads: thread.start() thread.join() if __name__ == "__main__": processes = [] for _ in range(3): p = multiprocessing.Process(target=bar) # create a new Process processes.append(p) for process in processes: process.start() process.join()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。