C++ library of multhreading on multi-platform


Can you please advise me what library is a good multithread library on cross-platform (linux and windows (both 32bit and 64bit). Thanks!



What do you actually call a “multithreaded library”, an interface to use program with threads ? I would dumbly suggest pthreads but if you could make your question more precise, it could help :)


I’ve used the Boost threading stuff and I liked it. I was testing it on Windows, and it worked fine – it can’t be worse on Linux. Easy to use, too.

I second the recommendation for boot::threads. It’s nice and simple without a lot of extra junk that you don’t need.


I would like to use pthreads. Has anyone use it for Win64 platform? It seems there is only pthreads for Win32 now.

I looked at boost thread or boost asio, they don’t have some functions to call pthread_suspend and pthread_resume.

It kind of depends what you want to do. Since you’re posting here, I’ll assume you want to split some sort of calculation over multiple processors.

If your calculation is contained in a for loop where all of the iterations are independent, OpenMP is the easiest way to go. Even if they are not totally independent, its mature enough that there are certain ways around this. If the computationally heavy part of your algorithm isn’t in a nice for loop, you could try the intel threading library. I haven always been very impressed with Intel’s products.

I’m trying to figure out how to use pthreads with nvcc on a windows platform. I want to use pthreads for the Host part of the C code, but it doesn’t recognize #include <pthread.h> in the code or -pthread on the cmd line. Any suggestions ?


windows doesn’t natively support pthreads; pthreads is native to linux. You’ll have to use a library that implements a wrapper for pthreads ontop of windows, e.g. http://www.sourceware.org/pthreads-win32/