gpt4 book ai didi

multithreading - std::thread::hardware_concurrency 是一个,我应该在我的系统上实现线程吗

转载 作者:行者123 更新时间:2023-12-03 13:15:03 26 4
gpt4 key购买 nike

当我 cout std::thread::hardware_concurrency 它给出 1。

但来自cppreference

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

如果目标只是我的系统,那么在我的系统上实现线程有什么用?

最佳答案

也许你忘记了括号!

cout << std::thread::hardware_concurrency;

在我的机器上总是报告“1”,但是

cout << std::thread::hardware_concurrency();

报告正确的核心数。

关于multithreading - std::thread::hardware_concurrency 是一个,我应该在我的系统上实现线程吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39684812/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com