offloading tasks to different threads in c++