Code: -------------------------------------------------------------- import time from concurrent.futures import ThreadPoolExecutor
def work_01(i): time.sleep(1) print(i)
def work_02(i): time.sleep(2) print(i)
def work_03(i): time.sleep(3) print(i)
with ThreadPoolExecutor(max_workers=5) as executor: for i in range(2): executor.submit(work_01, i) executor.submit(work_02, i) executor.submit(work_03, i)