Open this example in the interactive library
Source code
from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor(max_workers=2) as pool:
print(list(pool.map(lambda n: n*n, [1, 2, 3])))Sample output
[1, 4, 9]

Map work with a thread pool. A self-contained example using the Python standard library.
Open this example in the interactive library
from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor(max_workers=2) as pool:
print(list(pool.map(lambda n: n*n, [1, 2, 3])))[1, 4, 9]