<分区>
Possible Duplicate:
PThread vs boost::thread?
自从我了解什么是多线程以来,我一直在使用 pthreads 库编程示例。最近我在互联网上偶然发现了 Boost 线程库并且很好奇。谁能具体说明两者之间的显着区别是什么? Boost 是否提供了任何额外的特权,如果是,那么这些特权是什么?
<分区>
Possible Duplicate:
PThread vs boost::thread?
自从我了解什么是多线程以来,我一直在使用 pthreads 库编程示例。最近我在互联网上偶然发现了 Boost 线程库并且很好奇。谁能具体说明两者之间的显着区别是什么? Boost 是否提供了任何额外的特权,如果是,那么这些特权是什么?
最佳答案
boost::thread 的设计受到 pthreads 的强烈影响,但当然风格是 C++ 库而不是 C 库。以下是我想到的一些差异。我并不认为这是一份详尽的差异 list 。
pthreads 具有而 boost::thread 缺乏的东西:
When you use boost::thread you can grab the underlying
pthread_t
(orpthread_mutex_t
, etc.) by calling thenative_handle()
member function, and use it to regain back functionality not supplied directly by boost::thread.
pthread_attr_setschedparam
)pthread_attr_getstacksize
)pthread_mutex_getprioceiling
)boost::thread 具有 pthreads 缺乏的东西:
The following things can be done in pthreads (after all boost::thread is implemented on pthreads). But there isn't clear and direct API in pthreads to do these things.
关于c++ - Boost Thread 库或 Pthreads 的显着差异是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6928651/