在C++11引入了对多线程语言级别的支持之后,还有必要学习posix线程吗?
PHPz
PHPz 2017-04-17 11:41:57
0
3
765

C++11对多线程的支持很完善,互斥量,锁,条件变量,原子操作一应俱全,posix线程库还能另外提供的也就是记录锁,消息队列,但这些都可以在需要时自行实现.而且用C++原生线程库的代码还能够跨平台.
请问现在实际工程中涉及多线程的部分向C++11原生多线程库迁移的如何了?使用posix线程库进行开发的情况还多不多?

PHPz
PHPz

学习是最好的投资!

reply all(3)
黄舟

In POSIX systems, do you think you can get rid of PThread? It seems that the bottom layer is implemented by PThread. There is no problem at all simply using std::thread, but complex functions that need to be customized must be encapsulated based on PThread. STL is better at algorithms and containers, but multi-threading is not very good. Only represents personal opinion.

迷茫

I remember that the thread library of C++11 is packaged according to OpenMP. pThread is still inferior to OpenMP in terms of performance and usage. Personally, I think it can be understood. If you don't have time, there is no need to delve deeper.

阿神

I think: std::thread and so on provided by C++11 are not language-level support, but standard library support. In fact, there is no difference between c++ thread and pthread in terms of learning and usage (maybe pthread has more parameters?), and there are other things that pthread can provide as you mentioned. As for performance, I don't think there will be any difference between the two. More differences may be in portability.
So, I think we might as well learn both.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!