OS provides threads (syscalls to create new threads; scheduling services).
Unix libc has wrapper around OS threads with lot useful functions (like mutexes, cond vars, etc). Usually external interface of such system libraries is "POSIX threads" (functions named pthread_*
): http://en.wikipedia.org/wiki/POSIX_Threads
Windows has its own hard-to-use threading API (WINAPI's CreateThread
, etc). But there are wrappers around Windows API to get something like POSIX threads api (e.g. there is such libraries for mingw32 and cygwin; check wikipedia section)
C++11 std::thread
, boost's boost::thread
are just modern OS-independent wrappers around system threading API. They are used to create portable programs which can be compiled on any supported platform, without creating #ifdef
hell and/or writing own custom wrappers around system threading library. If your are creating new program, consider using this way.
There are several other threading wrappers, e.g. included in graphic libraries like QT or GTK+.
OpenMP implementations has internal support library (for example, gcc has libgomp) which uses system/libc threading APIs, for example libgomp uses POSIX threads. Some implementations may also include user-space thread switching via assembly (M:N threading model).
MPI has no thread library inside. MPI is used to create several processes and setup communication between them. But when MPI is used in multithreaded programs, it will use some threading API to do synchronization. For example, MPICH will use pthreads on unix.