PThread vs boost::thread?

Chris picture Chris · Jan 31, 2010 · Viewed 22.4k times · Source

Having no experience with threading in the past, which threading technique in C++ will be the easiest for a beginner? boost::thread or pthreads?

Answer

Duck picture Duck · Jan 31, 2010

I'll go in the opposite direction of everyone else - learn (or at least familiarize yourself with what is available in) pthreads.

Since boost is mainly just a wrapper around pthreads (on posix platforms) it helps to know what is going on underneath. In attempting to be generic, boost leaves the platform specific functionality unwrapped. In order to get to it you need to use the native_handle() calls. In order to use the native_handle() calls you need to know what the platform offers.

Think of it like sockets. There are dozens of socket classes and frameworks. But ultimately they wrap the underlying platform's socket API. Your understanding is always richer by knowing it - and knowing in what ways your class abstractions might have short comings.