thread::thread Constructor

thread::thread Constructor


Constructs a thread object.

thread() _NOEXCEPT;
template<class Fn, class... Args>
   explicit thread(Fn&& F, Args&&... A);
thread(thread&& Other) _NOEXCEPT;


An application-defined function to be executed by the thread.


A list of arguments to be passed to F.


An existing thread object.

The first constructor constructs an object that's not associated with a thread of execution. The value that's returned by a call to get_id for the constructed object is thread::id().

The second constructor constructs an object that's associated with a new thread of execution and executes the pseudo-function INVOKE that's defined in <functional>. If not enough resources are available to start a new thread, the function throws a system_error object that has an error code of resource_unavailable_try_again. If the call to F terminates with an uncaught exception, terminate is called.

The third constructor constructs an object that's associated with the thread that's associated with Other. Other is then set to a default-constructed state.


Header: thread

Namespace: std

© 2015 Microsoft