MultiThreading in Python
ThreadPoolExecutor
logging.info("Submitting thread_function in pool")
with ThreadPoolExecutor(max_workers=3) as executor:
executor.map(thread_function, [4])
logging.info("Submitted all the thread_function s ")
It holds the control until all the tasks have been completed as we have used context manager with
. It does implicit join
.
logging.info("Submitting thread_function in pool")
executor = ThreadPoolExecutor(max_workers=3)
executor.map(thread_function, [4])
logging.info("Submitted all the thread_function s ")
It runs the threads and control goes back to main thread. So, first log will come, then thread_function
log and immediately last log.