Thread pool implementation in c++