Reputation: 1006
I'm new to C++ (coming from C#) writing a multi-threaded C++ application and wondering what is better to use: std::thread
or its Boost counterpart?
I saw the following discussion in another Stack Overflow post, but still do not have the complete picture of why should I choose one over the other. If not starting a new program, should I use standard library or Boost threads?
Thanks!
Upvotes: 16
Views: 7263
Reputation: 1343
If you're not already using boost in your project, there is no reason to use boost::thread in favor of std::thread. That is unless you are using some feature from boost not available in the STL. std::thread is suitable enough for most use cases, and unless compelling arguments are presented, writing standard code is always preferable.
If however you are already using boost in your project, check out if boost::thread offers anything extra compared to std::thread.
Upvotes: 18
Reputation: 15075
Keep in mind that Boost.Thread is a portable library and compiles on a wide range of platfomrs/compilers - including those, where std::thread is unavailable.
Upvotes: 3
Reputation: 13558
It really depends on your habits and preferences.. With boost you have a whole set of libraries that make your life easier, but they will need to be installed on the system your program is compiled on while with std threads all you need is a cpp compiler.
Upvotes: 0