Archived
ThreadPoolExecutor dead simple example
An old note — I haven't updated it since I wrote it.
Create a ThreadPoolExecutor with 3 workers, and print something from each executor.
1from concurrent.futures import ThreadPoolExecutor
2
3
4def task():
5 print("Task Executed")
6
7
8executor = ThreadPoolExecutor(max_workers=3)
9executor.submit(task)
10executor.submit(task)