We recommend using Visual Studio 2017

<thread>

 

The latest version of this topic can be found at <thread>.

Include the standard header <thread> to define the class thread and various supporting functions.

#include <thread>  

System_CAPS_ICON_note.jpg Note

In code that is compiled by using /clr or /clr:pure, this header is blocked.

The __STDCPP_THREADS__ macro is defined as a nonzero value to indicate that threads are supported by this header.

Public Classes

NameDescription
thread ClassDefines an object that is used to observe and manage a thread of execution in an application.

Public Structures

NameDescription
hash Structure (STL)Defines a member function that returns a value that is uniquely determined by a thread::id. The member function defines a hash function that is suitable for mapping values of type thread::id to a distribution of index values.

Public Functions

NameDescription
get_id FunctionUniquely identifies the current thread of execution.
sleep_for FunctionBlocks the calling thread.
sleep_until FunctionBlocks the calling thread at least until the specified time.
swap FunctionExchanges the states of two thread objects.
yield FunctionSignals the operating system to run other threads, even if the current thread would ordinarily continue to run.

Public Operators

NameDescription
operator>= OperatorDetermines whether one thread::id object is greater than or equal to another.
operator> OperatorDetermines whether one thread::id object is greater than another.
operator<= OperatorDetermines whether one thread::id object is less than or equal to another.
operator< OperatorDetermines whether one thread::id object is less than another.
operator!= OperatorCompares two thread::id objects for inequality.
operator== OperatorCompares two thread::id objects for equality.
operator<< OperatorInserts a text representation of a thread::id object into a stream.

Header Files Reference
Thread Safety in the C++ Standard Library

Show: