Savoga

Threads


Start

Use std::thread t1(do_something);

.detach(): let run the thread in the background independently. Ideally stated right after starting the thread.

Finish

.join(): used to wait for a thread to finish. Note: we say “join” because the thread finishes in joining others e.g. it finishes in joining the main thread (example below).


int main() { 
	std::thread t(do_something);
	t.join();
}