These days I am reading the pdf Designing MT programs . It explains that the user MUST explicitly call detach()
on an object of class std::thread
in C++0x before that object gets out of scope. If you don't call it std::terminate()
will be called and the application will die.
I usually use boost::thread
for threading in C++. Correct me if I am wrong but a boost::thread
object detaches automatically when it get out of scope.
Is seems to me that the boost approach follow a RAII principle and the std doesn't.
Do you know if there is some particular reason for this?
See Question&Answers more detail:os