I'm looking for a good guide/tutorial on multithreading in C++ (and ideally in general). Can anyone point me to a good online resource?
EDIT: I intend to familiarize myself with either the boost threading library or the one from Poco.
Unit of Concurrency Multitasking - Multiple tasks/processes running concurrently on a single CPU. The operating system executes these tasks by switching between them very frequently. The unit of concurrency, in this case, is a Process. Multithreading - Multiple parts of the same program running concurrently.
Multithreading means that you have multiple threads of execution inside the same application. A thread is like a separate CPU executing your application. Thus, a multithreaded application is like an application that has multiple CPUs executing different parts of the code at the same time.
The Dr. Dobbs article "The Boost.Threads Library" is a short introduction to the subject, using one of the Boost C++ Libraries.
That's not a tutorial, but a good set of articles Effective Concurrency by Herb Sutter.
Take a look at Concurrent Programming on Windows by Joe Duffy. The book is relative new (November 2008) and covers theory and practice ranging topics from the Win32 API to .NET Framework 3.5.
(source: barnesandnoble.com)
If you mean to parallelize computation for multi-core, check out OpenMP. It has gcc and intel (I'm not sure about Visual C++) support, and is a lot easier than using primitives.
Check out this useful video-lectures from Intel: http://software.intel.com/en-us/videos/three-things-you-must-teach-module-1-recognizing-potential-parallelism/
This tutorial covers:
The video tutorial is very short: about 60 minutes, so I hope you will find it useful.
If you're going to use boost::thread, I'd make sure to check out Anthony Williams' website, blogs and articles he maintains boost::thread contributed to the C++0x library particularly the threading components and the information he provides is accurate, relevant and concise.
He also has a book coming out this fall on modern C++ threading called Concurrency in Action.
Joe Duffy's book and blog is also a good resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With