May-03-2023, 07:47 AM
import concurrent.futures from concurrent.futures import ThreadPoolExecutor def add(args): print('inside add') return sum(args) args = [(4, 2), (9, 3), (16, 2)] with ThreadPoolExecutor(max_workers=5) as executor: for result in executor.map(add, args): print(result)
Output:inside add
inside add
6
inside add
12
18
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs