# 1.1进程
from multiprocessing import Process
def fun(index):
pass
if __name__ == '__main__':
for i in range(10):
p = Process(target=fun,args=(1,))
p.start()
View Code
# 1.2进程池
from concurrent.futures import ProcessPoolExecutor
def fun(a,b):
print(a,b)
if __name__ == "__main__":
pool = ProcessPoolExecutor(10)
pool.submit(fun,1,2)
View Code
# 2.1线程
from threading import Thread
def fun(index):
pass
if __name__ == "__main__":
t = Thread(target=fun,args=(1,))
t.start()
View Code
# 2.2线程池
from concurrent.futures import ThreadPoolExecutor
def fun(a,b):
print(a,b)
if __name__ == "__main__":
tpool = ThreadPoolExecutor(10)
tpool.submit(fun,1,2)
View Code
-----------------------------------------------------------------------------------------------------------------------------------------