Why should I prefer one or another in practice?
What are technical differences except that std::thread is a class?
Why should I prefer one or another in practice? What are technical differences except
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to run code on many platforms, go for Posix Threads. They are available almost everywhere and are quite mature. On the other hand if you only use Linux/gcc
std::threadis perfectly fine – it has a higher abstraction level, a really good interface and plays nicely with other C++11 classes.The C++11
std::threadclass unfortunately doesn’t work reliably (yet) on every platform, even if C++11 seems available. For instance in native Androidstd::threador Win64 it just does not work or has severe performance bottlenecks (as of 2012).A good replacement is
boost::thread– it is very similar tostd::thread(actually it is from the same author) and works reliably, but, of course, it introduces another dependency from a third party library.Edit: As of 2017,
std::threadmostly works on native Android. Some classes, likestd::timed_mutexare still not implemented.