std::jthread::hardware_concurrency

Returns the number of concurrent threads supported by the implementation. The value should be considered only a hint.

# Declarations

static unsigned int hardware_concurrency() noexcept;

(since C++20)

# Return value

Number of concurrent threads supported. If the value is not well defined or not computable, returns 0.

# Example

#include <iostream>
#include <thread>
 
int main()
{
    unsigned int n = std::jthread::hardware_concurrency();
    std::cout << n << " concurrent threads are supported.\n";
}

# See also