In this example, we analyze the creation of an object of the ThreadPoolExecutor class. We define a view_thread() function that allows us to display the current thread identifier with the threading.get_ident() method.
We define our main function where the executor object is initialized as an instance of the ThreadPoolExecutor class and over this object we execute a new set of threads. Then we obtain the thread has been executed with the threading.current_thread() method.
You can find the following code in the threadPoolConcurrency.py file in concurrency subfolder:
#python 3from concurrent.futures import ThreadPoolExecutorimport threadingimport randomdef view_thread(): print("Executing Thread") print("Accesing ...