10
edits
Changes
no edit summary
});
</syntaxhighlight>
3. functor
std::thread c(f);
</syntaxhighlight>
We need to decide If we want to wait for it to finish (join) or If we want it to run in the background (detach) before the thread object being deconstructed, because it will call std::terminate in the deconstructor and throw a error in runtime.
t.join() -------- synchronized function called in parent thread to wait for the child thread to finish.
t.detach() ------- let threads to run in the background.