import time from concurrent.futures import ThreadPoolExecutor def func(i): time.sleep(2) print(i) return i**2 tpool = ThreadPoolExecutor(max_workers = 5) t_lst = [] for i in range(10): t = tpool.submit(func,i) t_lst.append(t) tpool.shutdown() print("主线程") for t in t_lst: print("***",t.result())