A thread of execution
(also known as a thread
) is a single flow of
control within a program, including the initial invocation of a specific
top-level function, and recursively including every function invocation
subsequently executed by the thread.
When one thread creates another,
the initial call to the top-level function of the new thread is executed by the
new thread, not by the creating thread.
— end note
Every thread in a program can
potentially access every object and function in a program.
Under a hosted
implementation, a C++ program can have more than one thread running
The execution of each thread proceeds as defined by the remainder
of this document.
The execution of the entire program consists of an execution
of all of its threads.
Usually the execution can be viewed as an
interleaving of all its threads.
However, some kinds of atomic operations, for
example, allow executions inconsistent with a simple interleaving, as described
— end note
Under a freestanding implementation, it is
implementation-defined whether a program can
have more than one thread of execution.