Hey guys,

I'm interested in learning about simple multithreading in C++ for Windows. Does anyone have any reccommended tutorials/links thats quite good?

Recommended Answers

All 2 Replies

There are a lot of tutorials out there on this topic. Here are a few:


Also, the standard C++11 threading library is almost entirely based on the Boost.Thread library (the Boost libraries is sort of the anti-chamber for creating and testing to-be-standard libraries). So, you can also follow tutorials and documentation on using Boost.Thread, because it has a longer history of being used by people and thus, has more material to read about it.

Also, getting C++11 threads to work on Windows could be a bit tricky. You will need either Visual Studio 2013 (anything older will not support it, or at least, not well), or a bleeding-edge version of GCC from MinGW-w64 (notice that the "new" features include "Winpthread: new library, pthreads implementation for Windows") or from TDM-GCC (notice that the change-log says "C++11 concurrency features (including std::thread) are now available.").

If you can't get C++11 threads to work, you should use Boost.Thread, which is, as I said, virtually identical to the standard C++11 thread library (but works on older compilers too, and on Windows).

Finally, you should also know that most of the difficulties related to writing multi-threaded applications are language-independent. So, you might want to do some research on that topic, not specifically for C++. Writing multi-threaded application is an art and it can be very challenging (and very frustrating at times), and all that has nothing to do with the language or the library you use. There are some good resources on that like "The Little Book of Semaphores" or "An Introduction to Parallel Programming".

commented: As usual, Mike2K gives good advice. +12

Multithreading is a specialized form of multitasking and a multitasking is the feature that allows your computer to run two or more programs concurrently. In general, there are two types of multitasking: process-based and thread-based.

Process-based multitasking handles the concurrent execution of programs. Thread-based multitasking deals with the concurrent execution of pieces of the same program.

A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.

C++ does not contain any built-in support for multithreaded applications. Instead, it relies entirely upon the operating system to provide this feature.

commented: I am forced to downvote because it is WRONG. C++ does contain built-in support for multi-threading. You have cut and paste this information from another website which is presenting out-of-date information. -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.