返回当前系统支持的并发线程数。
注意:应该把这个当成提示。
static unsigned int hardware_concurrency() noexcept;
参数(无)
返回值
支持的并发线程数。若该值非良定义或不可计算,则返回 0 。
#include <iostream>
#include <thread>
int main() {
unsigned int n = std::thread::hardware_concurrency();
std::cout << " concurrent threads are supported = " << n << std::endl;
}

本文介绍了如何使用C++标准库中的`std::thread::hardware_concurrency()`函数来获取当前系统支持的并发线程数。示例代码展示了如何在main函数中调用此函数并输出结果。
2496

被折叠的 条评论
为什么被折叠?



