[intro.multithread.general] (original) (raw)

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.

[Note 1:

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.37

Under a hosted implementation, a C++ program can have more than one thread running concurrently.

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.

[Note 2:

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 below.

— _end note_]

Under a freestanding implementation, it is implementation-defined whether a program can have more than one thread of execution.