std::thread Class Reference
Concurrency » Threads

`#include <thread>`

## Classes

class | id

## Public Types

using | native_handle_type

## Public Member Functions

template<typename _Callable, typename... _Args, typename = _Require<__not_same<_Callable>>>
| thread (_Callable &&__f, _Args &&... __args)
| thread (const thread &)=delete
| thread (thread &&__t) noexcept
void | detach ()
id | get_id () const noexcept
void | join ()
bool | joinable () const noexcept
native_handle_type | native_handle ()
thread & | operator= (const thread &)=delete
thread & | operator= (thread &&__t) noexcept
void | swap (thread &__t) noexcept

## Static Public Member Functions

static unsigned int | hardware_concurrency () noexcept

## Related Symbols

(Note that these are not member symbols.)
bool | operator== (thread::id __x, thread::id __y) noexcept
void | swap (thread &__x, thread &__y) noexcept

## Detailed Description

A std::thread represents a new thread of execution.

The default constructor creates an object that does not own a thread. The thread(F&&, Args&&...) constructor invokes a callable in a new thread, and owns that new thread. A std::thread that owns a thread is joinable. Joining a thread waits for it to finish executing, which happens when the callable running in that thread returns.

A std::thread cannot be copied, but can be moved. Moving a joinable object transfers ownership of its thread to another object.

A joinable std::thread must be explicitly joined (or detached) before it is destroyed or assigned to. Attempting to destroy a joinable thread will terminate the whole process.

Since
  C++11

Definition at line 78 of file std_thread.h.

## Member Typedef Documentation

## native_handle_type

using std::thread::native_handle_type

Definition at line 82 of file std_thread.h.

## Constructor & Destructor Documentation

## thread() [1/2]

template<typename _Callable, typename... _Args, typename = _Require<__not_same<_Callable>>>

std::thread::thread | ( | _Callable && | __f,
|  | _Args &&... | __args )

inline explicit

Definition at line 154 of file std_thread.h.

## ~thread()

std::thread::~thread | ( |  | ) |

inline

Definition at line 170 of file std_thread.h.

## thread() [2/2]

std::thread::thread | ( | thread && | __t | ) |

inline noexcept

Definition at line 178 of file std_thread.h.

## Member Function Documentation

## get_id()

id std::thread::get_id | ( |  | ) | const

inline noexcept

Definition at line 206 of file std_thread.h.

## joinable()

bool std::thread::joinable | ( |  | ) | const

inline noexcept

Definition at line 196 of file std_thread.h.

## native_handle()

native_handle_type std::thread::native_handle | ( |  | ) |

inline

Precondition
  thread is joinable

Definition at line 212 of file std_thread.h.

## operator=()

thread & std::thread::operator= | ( | thread && | __t | ) |

inline noexcept

Definition at line 183 of file std_thread.h.

## swap()

void std::thread::swap | ( | thread & | __t | ) |

inline noexcept

Definition at line 192 of file std_thread.h.

The documentation for this class was generated from the following file:

- std_thread.h