Thread::hardware_concurrency is an in-built function in C++ std::thread. It is an observer function which means it observes a state and then returns the corresponding output. This function returns the number of concurrent threads supported by the available hardware implementation. This value might not always be accurate.
Parameters: This function does not accept any parameters.
Return Value: It returns a non-negative integer denoting the number of concurrent threads supported by the system. If the value is either not computable or not well defined it returns 0.
Below program demonstrate the use of std::thread::joinable()
Note: On the online IDE this program will show error. To compile this, use the flag “-pthread” on g++ compilers compilation with the help of command “g++ –std=c++14 -pthread file.cpp”.
Number of concurrent threads supported are: 4
- Thread get_id() function in C++
- Thread joinable() function in C++
- Print numbers in sequence using thread synchronization
- Function Overloading vs Function Overriding in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- Difference between Virtual function and Pure virtual function in C++
- fma() function in C++
- log() function in C++
- exp() function C++
- div() function in C++
- regex_iterator() function in C++ STL
- valarray sin() function in C++
- map rbegin() function in C++ STL
- max() function for valarray in C++
- map rend() function in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.