Perhaps the author just wanted to demonstrate creating a thread pool to limit the number of threads that can be opened, and did not consider the complete project. For example, the threads in the thread pool must be reusable and cannot be created and closed frequently; the size of the thread pool can be dynamically adapted. When there are a certain number of idle threads, some will be shut down. When the threads are full and there are not enough, appropriate Add some threads. Specifically, I think if you can look up relevant information, there will definitely be a solution.
I think your statement is right.
Output:
Indicates that the thread has indeed exited.
Perhaps the author just wanted to demonstrate creating a thread pool to limit the number of threads that can be opened, and did not consider the complete project. For example, the threads in the thread pool must be reusable and cannot be created and closed frequently; the size of the thread pool can be dynamically adapted. When there are a certain number of idle threads, some will be shut down. When the threads are full and there are not enough, appropriate Add some threads. Specifically, I think if you can look up relevant information, there will definitely be a solution.
He didn’t write in the main thread
q.join()