# How to do thread management in C++?

We use pthread for thread management in C based systems. pthread is in general compilable by C++ compiler (like g++). However, what are the better ways of abstractions for threads in C++?

Also, for making any system to be working in a multi-threaded system, it is also important to make thread safe. What are the standard libraries that requires alternative (installs) to be thread safe or are they unsafe for multi-threaded environments?

Is smart pointers, templates require special measures to make it safe?

What are the best practices for the thread managements in C++?

• @stijn: This is a standard C++ library (not compiler) feature and many compilers can be used with multiple standard C++ libraries. The GNU stdlibc++ (that comes with gcc) mostly supports it as does (except atomic) the LLVM libcxx (that comes with clang; clang can also be used with the GNU one). I don't know about Visual Studio 2010, but you can use the Boost version (which is interchangeable) with almost any compiler (no atomic there either though). There is also Apache stdcxx implementation that can be used with most compilers. – Jan Hudec Nov 16 '11 at 7:08