C++11 std::threads vs posix threads

后端 未结 4 2005
广开言路
广开言路 2020-12-02 04:05

Why should I prefer one or another in practice? What are technical differences except that std::thread is a class?

4条回答
  •  长情又很酷
    2020-12-02 04:35

    The std::thread library is implemented on top of pthreads in an environment supporting pthreads (for example: libstdc++).

    I think the big difference between the two is abstraction. std::thread is a C++ class library. The std::thread library includes many abstract features, for example: scoped locks, recursive mutexes, future/promise design pattern implementations, and more.

提交回复
热议问题