CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 21 Jul 2025 22:03:49 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/thread/thread/
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 21 Jul 2025 22:03:49 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"7644-f4C45rb+A3aSN7Y4q9nGxZHdHfs"
Content-Encoding: gzip
Class to represent individual threads of execution.
A thread of execution is a sequence of instructions that can be executed concurrently with other such sequences in multithreading environments, while sharing a same address space.
An initialized thread object represents an active thread of execution; Such a thread object is joinable, and has a unique thread id.
A default-constructed (non-initialized) thread object is not joinable, and its thread id is common for all non-joinable threads.
A joinable thread becomes not joinable if moved from, or if either join or detach are called on them.
Output:
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<thread>
classes
-
threadC++11
-
namespaces
-
this_threadC++11
-
thread
-
thread::~threadC++11
-
thread::threadC++11
member functions
-
thread::detachC++11
-
thread::get_idC++11
-
thread::joinC++11
-
thread::joinableC++11
-
thread::native_handleC++11
-
thread::operator=C++11
-
thread::swapC++11
-
member types
-
thread::idC++11
-
thread::native_handle_typeC++11
-
static member functions
non-member overloads
-
swap (thread)C++11
-
class
<thread>
std::thread
class thread;
Thread
A thread of execution is a sequence of instructions that can be executed concurrently with other such sequences in multithreading environments, while sharing a same address space.
An initialized thread object represents an active thread of execution; Such a thread object is joinable, and has a unique thread id.
A default-constructed (non-initialized) thread object is not joinable, and its thread id is common for all non-joinable threads.
A joinable thread becomes not joinable if moved from, or if either join or detach are called on them.
Member types
- id
- Thread id (public member type)
- native_handle_type
- Native handle type (public member type)
Member functions
- (constructor)
- Construct thread (public member function)
- (destructor)
- Thread destructor (public member function)
- operator=
- Move-assign thread (public member function)
- get_id
- Get thread id (public member function)
- joinable
- Check if joinable (public member function)
- join
- Join thread (public member function)
- detach
- Detach thread (public member function)
- swap
- Swap threads (public member function)
- native_handle
- Get native handle (public member function)
- hardware_concurrency [static]
- Detect hardware concurrency (public static member function)
Non-member overloads
- swap (thread)
- Swap threads (function)
Example
|
|
Output:
main, foo and bar now execute concurrently... foo and bar completed. |
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us