Documentation Home >> Headers >> <thread> Header >> std::thread >> std::thread Constructor

Construct a std::thread object associated with a new thread of execution.

template<typename Callable,typename Args...>
explicit thread(Callable func,Args... args);


func and each element of args must be MoveConstructible


Constructs a std::thread instance, and associates it with a newly-created thread of execution. Copies or moves func and args into internal storage associated that persists for the lifetime of the new thread of execution. Runs the supplied function func on that new thread of execution by INVOKE(func,args).


For a newly-constructed std::thread object x, x.get_id()!=id().


An exception of type std::system_error if unable to start the new thread. Any exception thrown by copying func or args into internal storage.


The invocation of the constructor happens-before the execution of the supplied function on the newly-created thread of execution.


On compilers that don't support variadic templates, an overloaded set of constructors is provided that supports passing of up to 5 arguments.


#include <thread>

See Also