Please note that this course is currently being updated. All the videos are being re-recorded, and new material will be added. I will try to minimize disruption, but there may be times when it is unavoidable.
Please note that this course is currently being updated. All the videos are being re-recorded, and new material will be added. I will try to minimize disruption, but there may be times when it is unavoidable.
Multithreading is used in many areas of computing, including graphics processing, machine learning and Internet stores. An understanding of threads is essential to make full use of the capabilities of modern hardware.
C++ now provides direct support for threads, making it possible to write portable multithreaded programs which have well-defined behaviour, without requiring any external libraries.
This course thoroughly covers the basics of threading and will prepare you for more advanced work with threads. Source code is provided for all the examples. No previous knowledge of threading is required, but you should be comfortable with programming in C++ at an intermediate level, using "Modern" features such as smart pointers and move semantics.
We start with the concepts of multithreading and learn how to launch threads in C++. We look at the problems which can occur with multiple threads and how to avoid them.
C++ provides tools which allow us to work at a higher level of abstraction than system threads which share data; we cover condition variables and promises with futures. We will also look at asynchronous, lock-free and parallel programming, including atomic variables and the parallel algorithms in C++17. We will finish the course by implementing a concurrent queue and thread pool, which will bring together the material you have learnt.
There are downloadable exercises for each video, with solutions, so you can check your understanding as you learn, gaining familiarity and confidence with the material. There are also some optional assignments, which are more challenging.
I will be actively supporting the course. I will respond promptly if you have any questions or experience difficulties with the course content. Please feel free to use the Q&A feature or alternatively you can send me a private message.
Initializers, literals, auto and range-for loops.
Lambda expressions.
Move semantics.
Lvalues and rvalues.
Move-only objects, random numbers.
A closer look at the C++ thread class.
How to manage a launched thread.
Launching multiple threads. This is where the "fun" starts!
Example of a data race.
How to overcome a problem with using mutexes directly.
A more fully-featured wrapper class that overcomes a problem with using mutexes directly.
How to wait for a lock on a mutex without blocking indefinitely.
Avoid unnecessary locking when there are many more reading threads than writers.
How to initialize shared data safely. Threadsafe Singleton implementation.
How to create data that is local to a thread.
How to create an atomic variable
How to write a spin lock
Odds and ends to finish off the section.
Introduce the basic concept of parallelism
Introduction to execution policies
How to choose an execution policy, implications for exception handling
A brief look at the new parallel algorithm functions in C++17.
We continue our brief look at the new parallel algorithm functions in C++17.
Hands-on session where we create a basic concurrent queue.
How to really improve the performance of thread-intensive programs.
Hands-on session where we create a basic thread pool.
OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.
Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.
Find this site helpful? Tell a friend about us.
We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.
Your purchases help us maintain our catalog and keep our servers humming without ads.
Thank you for supporting OpenCourser.