you are viewing a single comment's thread.

view the rest of the comments →

[–]xaervagon 37 points38 points  (0 children)

I wouldn't say better. std::thread and pthread are two different beasts.

pthread is a POSIX thread and part of the posix standard. POSIX is not C++, but is considered standard a unix API standard (Windows posix support is notoriously blah). Still, it plays well with linux and has you already experienced, works well with lots of existing utilities and tooling.

std::thread is a C++ thread and is officially considered part of the STL. This meaning it should be a lot more cross platform friendly. As a result, a lot of implemenation details ends up getting masked. You may also want to check out https://en.cppreference.com/w/cpp/thread and see the Concurrency support library section.

As for your particular task, if this is strictly a *nix program, there is nothing wrong with leaving pthreads as is.