Reputation: 3521
Is it possible to reuse python thread object to avoid unnecessary creation of the thread? It could be useful in the following situation. There are many tasks which must be parallelized using thread pool which size is much less than the number of the tasks.
I know that there is multiprocessing.Pool, but it is very important to use threads not processes.
Upvotes: 3
Views: 5363
Reputation: 19368
If you're using Python 3, the best way is definetly to use concurrent.futures.ThreadPoolExecutor
.
Actually you should read the whole documentation of concurrent.futures
, it's not long, and there are many great examples.
Upvotes: 3