thread Class

Defines an object that's used to observe and manage a thread of execution within an application.

class thread;

You can use a thread object to observe and manage a thread of execution within an application. A thread object that's created by using the default constructor is not associated with any thread of execution. A thread object that's constructed by using a callable object creates a new thread of execution and calls the callable object in that thread. Thread objects can be moved but not copied. Therefore, a thread of execution can be associated with only one thread object.

Every thread of execution has a unique identifier of type thread::id. The function this_thread::get_id returns the identifier of the calling thread. The member function thread::get_id returns the identifier of the thread that's managed by a thread object. For a default-constructed thread object, the thread::get_id method returns an object that has a value that's the same for all default-constructed thread objects and different from the value that's returned by this_thread::get_id for any thread of execution that could be joined at the time of the call.



thread::id Class

Uniquely identifies the associated thread.



thread::thread Constructor

Constructs a thread object.



thread::detach Method

Detaches the associated thread from the thread object.

thread::get_id Method

Returns the unique identifier of the associated thread.

thread::hardware_concurrency Method

Static. Returns an estimate of the number of hardware thread contexts.

thread::join Method

Blocks until the associated thread completes.

thread::joinable Method

Specifies whether the associated thread is joinable.

thread::native_handle Method

Returns the implementation-specific type that represents the thread handle.

thread::swap Method

Swaps the object state with a specified thread object.



thread::operator= Operator

Associates a thread with the current thread object.

Header: thread

Namespace: std

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft