多进程
多进程的语法和多线程的语法是一样的,只不过是import的名称不一样而已。
import multiprocessing
import multiprocessing,time,threading
def thread_id()
print(threading.get_ident())#查看
def run(name): print("hello %s"%name) time.sleep(2) if __name__ == '__main__': count=0 while True: r=multiprocessing.Process(target=run,args=("alex%s"%count,)) r.start() count+=1

浙公网安备 33010602011771号