Implementing A Thread Pool We will have a vector (or linked list) of 'pthread_t' to be able to account for the threads in the pool, and 'join' them when they terminate. All threads will execute the same function. This function blocks on a condition variable. The condition expression checks both if the queue is not empty, and whether some pool-wise flag tells us the pool is being terminated, or a per-thread flag tells us our specific thread should exit.