Java style Pthreads library in C++