gpt4 book ai didi

c++ - 我应该更喜欢 std::thread 还是 Boost 线程?

转载 作者:IT老高 更新时间:2023-10-28 22:27:01 37 4
gpt4 key购买 nike

我是 C++ 新手(来自 C#),正在编写一个多线程 C++ 应用程序,想知道什么更好用:std::thread 或它的 Boost 对应物?

我看到了following discussion在另一个 Stack Overflow 帖子中,但仍然没有完全了解我为什么要选择一个而不是另一个。如果不启动新程序,我应该使用标准库还是 Boost 线程?

谢谢!

最佳答案

如果您尚未在项目中使用 boost,则没有理由使用 boost::thread 来支持 std::thread。除非您使用的是 STL 中不可用的 boost 中的某些功能。 std::thread 足够适用于大多数用例,除非提出令人信服的论据,否则编写标准代码始终是可取的。

如果您已经在项目中使用了 boost,请检查 boost::thread 与 std::thread 相比是否提供了额外的功能。

关于c++ - 我应该更喜欢 std::thread 还是 Boost 线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12365196/

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