Use thread::hardware_concurrency method to get the number of simultaneous threads supported - C++ Thread

C++ examples for Thread:Thread Creation

Description

Use thread::hardware_concurrency method to get the number of simultaneous threads supported

Demo Code

#include <iostream>
#include <thread>

using namespace std;

int main(int argc, char* argv[])
{
    const unsigned int numberOfProcessors{ thread::hardware_concurrency() };

    cout << "This system can run " << numberOfProcessors << " concurrent tasks" << endl;

    return 0;/* w w  w .java  2s. c  om*/
}

Result


Related Tutorials