C++ Language/Std/Multithreading/ThreadCreation

From Wikibooks, open books for an open world
Jump to navigation Jump to search

To create a thread in modern C++, instantiate std::thread, passing it a callable-object for the worker thread's entry point.

To block yourself for an arbitrary amount of time, call std::this_thread::sleep_for(). To block yourself until the worker thread has finished its work, call oThread.join().

Additional information about thread creation