Stopping a Thread Pool
The stop() member is used to shut down the thread pool.
Calling stop() to shut down a thread pool causes the thread pool to close the work queue after the thread pool completes all work presently enqueued. Then thread pool joins and removes each thread in the thread pool. Each thread pool will stop only after completing execution of any enqueued work. Should a work functor within the pool be deadlocked or running in an infinite loop, then the thread pool will never complete its shutdown.