##线程加入子进程
# python多线程 不适合CPU密集型操作的任务,适合io操作密集型的任务
#多进程
import multiprocessing
import time,threading
def thread_run():
print(threading.get_ident())
def run(name):
time.sleep(2)
print(‘hello’,name)
t= threading.Thread(target=thread_run,)
t.start()
if __name__==’__main__’:
for i in range(10):
p= multiprocessing.Process(target=run,args=(‘tom %s’%i,))
p.start()
版权声明:本文为qq_42535601原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。