switched from pthreads to std::thread