问题描述
为什么我应该在实践中偏好某一个?
除了std :: thread是一个类之外,什么是技术差异?
Why should I prefer one or another in practice?What are technical differences except that std::thread is a class?
推荐答案
许多平台,去Posix线程。他们几乎无处不在,而且相当成熟。另一方面,如果你只使用Linux / gcc std :: thread
是完全正确的 - 它有一个更高的抽象级别,一个非常好的接口,并与其他C + +11类。
If you want to run code on many platforms, go for Posix Threads. They are available almost everywhere and are quite mature. On the other hand if you only use Linux/gcc std::thread
is perfectly fine - it has a higher abstraction level, a really good interface and plays nicely with other C++11 classes.
不幸的是,C ++ 11 std :: thread
)在每个平台上,即使C ++ 11似乎可用。例如在本地Android std :: thread
或Win64它只是不工作或有严重的性能瓶颈(2012年)。
The C++11 std::thread
class unfortunately doesn't work reliably (yet) on every platform, even if C++11 seems available. For instance in native Android std::thread
or Win64 it just does not work or has severe performance bottlenecks (as of 2012).
一个很好的替换是 boost :: thread
- 它非常类似于 std :: thread
实际上是来自同一个作者)和工作可靠,但当然,它引入了另一个依赖从第三方库。
A good replacement is boost::thread
- it is very similar to std::thread
(actually it is from the same author) and works reliably, but, of course, it introduces another dependency from a third party library.
这篇关于C ++ 11 std :: threads和posix threads的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!