The class
thread provides a mechanism to create a new thread of execution, to join with
a thread (i.e., wait for a thread to complete), and to perform other operations that manage and
query the state of a thread
. A
thread object uniquely represents a particular thread of
execution
. That representation may be transferred to other
thread objects in such a way
that no two
thread objects simultaneously represent the same thread of execution
. A
thread of execution is
detached when no
thread object represents that thread
. Objects of class
thread can be in a state that does not represent a thread of
execution
. [
Note 1:
A
thread object does not represent a thread of execution after
default construction, after being moved from, or after a successful call to
detach or
join. —
end note]
namespace std {
class thread {
public:
class id;
using native_handle_type = implementation-defined;
thread() noexcept;
template<class F, class. Args> explicit thread(F&& f, Args&&. args);
~thread();
thread(const thread&) = delete;
thread(thread&&) noexcept;
thread& operator=(const thread&) = delete;
thread& operator=(thread&&) noexcept;
void swap(thread&) noexcept;
bool joinable() const noexcept;
void join();
void detach();
id get_id() const noexcept;
native_handle_type native_handle();
static unsigned int hardware_concurrency() noexcept;
};
}