views:

229

answers:

3

Hello all.

I would like to learn how to build a multi-threaded application, but I don't even really know where to start.

How do most people implement multi-threading? Do they use the boost library? Is there some other way to do it? (using standard C / C++)

I understand the concept, but totally have no idea where to even start to actually learn how to do it. Can anyone recommend anything?

http://msdn.microsoft.com/en-us/library/7t9ha0zh%28v=VS.80%29.aspx <--- Are these standard C++, or some Microsoft-only implementation?

Am I correct that the multithreading libraries are contained in the Windows API? I found an example on MSDN ( http://msdn.microsoft.com/en-us/library/esszf9hw%28v=VS.80%29.aspx) and the functions it uses (ReleaseMutex, etc) seem to be in windows.h. Is this what most people are using when they do Windows programming?

Thanks!

Russel

+3  A: 

Boost library is a cross-platform way of using threads.

Most people use winapi or pthreads. pthreads was originally used on POSIX systems but there is a port of it for mingw allowing its use on windows too.

I'd recommend using boost if you absolutely need cross-platform solution, or already have boost libraries linked. If you are developing for windows or POSIX, use winapi or pthreads correspondingly.

Basilevs
Just use boost - Boost.Thread and Boost.Bind are my two favorite friends this week.
Chris Kaminski
I've used [winpthreads](http://sourceware.org/pthreads-win32/) with MSVC too.
sje397
A: 

If you have never before dealt with multithreading, i'd suggest you work yourself through a tutorial like this one on codeproject to get started.

sum1stolemyname
+2  A: 

If you are looking for a simple performance boost for in your application through multi-threading OpenMP is a simple library that will allow your program to scale across multiple cores, requiring only #pragma placement in your code to parallelize blocks of code or loops, with additional options to weak specific performance.

This doesn't easily allow for coarse parallelism like a GUI/processing/IO division in the application, but does allow for easily visible multi-threading performance boosts on multi-core machines in heavy number-crunching.

phoenixillusion