import time from concurrent.futures import ThreadPoolExecutor def aa(a): print("aaaaaa") time.sleep(2) with ThreadPoolExecutor(max_workers=2) as t: while True: time.sleep(10) t.submit(aa, 1)