from concurrent.futures import ThreadPoolExecutor
executor = ThreadPoolExecutor(max_workers=10)
def test_main():
executor.submit(test2())
executor.submit(test3())
print(f"test1")
def test2():
time.sleep(5)
print(f"test2")
def test3():
time.sleep(2)
print(“test3”)
executor.submit(test_main())
这段代码中,运行结果是test2走完等待了2秒才走到test3, 这样的话线程池的作用好像就没有发挥出来了呀