from concurrent.futures import ThreadPoolExecutor
from concurrent.futures import as_completed
values = [2,3,4,5]
def square(n):
return n * n
with ThreadPoolExecutor(max_workers = 3) as executor:
results = executor.map(square, values:list)
for result in as_completed(results):
print(result)