We may earn an affiliate commission when you visit our partners.
Course image
James Raynard

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.

Read more

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.

Enroll now

What's inside

Learning objectives

  • How to write portable multi-threaded code in c++
  • Basic principles of multi-threading which will be applicable in all languages
  • Understanding of concurrency
  • Knowledge of c++17 parallel algorithms

Syllabus

Introduction
Lecturer Introduction
Guide to Exercises and Source Code
Review of the Modern C++ Features used in this course
Read more

Initializers, literals, auto and range-for loops.

Lambda expressions.

Move semantics.

Lvalues and rvalues.

Move-only objects, random numbers.

Introduction to Concurrency
Concurrency Introduction
Concurrency Motivation
Concurrency Overview
Threaded Program Structure
A Brief History of C++ Concurrency
Launching a Thread
Thread Function with Arguments
Computer with Single Processor
Computer with Single Processor and Cache
Computer with Multiple Processors
Synchronization Issues
How to create threads, understand concept of data race between multiple threads
System Thread Interface

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.

Data Races
Data Race Consequences
How to launch multiple threads without risking a data race
Critical Sections
Mutex Introduction
Mutex Class
Internally Synchronized Class

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.

Multiple Reader,Single Writer

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.

Lazy initialization
Double-checked Locking
Deadlock
Deadlock Practical
Deadlock Avoidance
Deadlock Avoidance Practical
Livelock
Future and Promise Classes
Livelock Practical
Mutex Conclusion
How to use higher-level types to manage multiple threads
Thread Coordination
Thread Coordination Practical
Condition Variables
Condition Variables with Predicate
Condition Variable Practical
Futures and Promises Overview
Futures and Promises Examples
Promises with Multiple Waiting Threads
Write thread-safe programs without using mutexes
Integer Operations and Threads

How to create an atomic variable

Double-checked Locking Reprise

How to write a spin lock

Lock-free Programming
Lock-free Programming Continued
Lock-free Programming Practical
Lock-free Programming Practical Continued
How to avoid waiting for a task to complete
Asynchronous Programming
Packaged Task
Packaged Task Assignment
The async Function
The async Function and Launch Options

Odds and ends to finish off the section.

Basic understanding of parallelism, use of C++17 parallel algorithms

Introduce the basic concept of parallelism

Parallelism Overview Continued
Data Parallelism Practical
Standard Algorithms Overview

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.

Parallel Algorithms Practical
New Parallel Algorithms Conclusion
Learn how to write a concurrent queue and a thread pool
Data Structures and Concurrency
Shared Pointer
Monitor Class
Monitor Class Continued
Semaphore

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.

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Teaches multithreading, which is a cornerstone of modern programming, a key topic for intermediate and advanced coders
Taught by James Raynard, a recognized expert in multithreading and industry thought leader
Examines C++, a key tool used in graphics processing, machine learning, and Internet stores
Provides exercises, solutions, and optional assignments to help learners check their understanding as they progress
This intermediate course requires comfort with C++ at an intermediate level

Save this course

Save Learn Multithreading with Modern C++ to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Learn Multithreading with Modern C++ with these activities:
Review asynchronous programming concepts
Refreshing your knowledge of asynchronous programming will provide a solid foundation for understanding how to avoid thread blocking effectively and handle tasks efficiently.
Browse courses on Asynchronous Programming
Show steps
  • Review notes or articles on asynchronous programming concepts.
  • Go through code examples or tutorials that demonstrate asynchronous programming in C++.
Organize and review course materials
Regularly organizing and reviewing your course materials will help you stay on top of the content and improve your retention and comprehension.
Show steps
  • Go through your notes, assignments, quizzes, and exams.
  • Identify any gaps in your understanding.
  • Revisit relevant sections of the course material to fill those gaps.
Follow tutorials on advanced multithreading techniques
Exploring tutorials on advanced multithreading techniques will broaden your knowledge and expose you to different approaches and best practices.
Browse courses on Concurrency
Show steps
  • Identify reputable sources or platforms offering tutorials on advanced multithreading concepts.
  • Select tutorials that align with your learning objectives.
  • Follow the tutorials, taking notes and implementing the code examples provided.
Three other activities
Expand to see all activities and additional details
Show all six activities
Practice C++ multithreading exercises
Completing each of the downloadable exercises with solutions will help you improve your understanding of multithreading concepts and apply them effectively in C++.
Show steps
  • Review the instructions and exercise description.
  • Attempt to solve the exercise on your own.
  • Check your solution against the provided solutions.
Write a blog post on a multithreading topic
Writing a blog post will help you synthesize and reinforce your understanding of multithreading concepts, while also potentially benefiting others who read your post.
Browse courses on Multithreading
Show steps
  • Choose a specific topic related to multithreading based on the course content.
  • Research and gather information on the topic.
  • Outline and draft your blog post.
  • Revise and edit your post for clarity and accuracy.
Build a multithreaded web server
Developing a web server using multithreading techniques will provide a practical application of the concepts covered in the course, allowing you to solidify your understanding.
Browse courses on Multithreading
Show steps
  • Choose a suitable web framework and development environment.
  • Design and implement a multithreaded architecture for handling client requests.
  • Test and debug the web server to ensure it handles multiple requests efficiently.
  • Deploy the web server and monitor its performance.

Career center

Learners who complete Learn Multithreading with Modern C++ will develop knowledge and skills that may be useful to these careers:

Reading list

We haven't picked any books for this reading list yet.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Here are nine courses similar to Learn Multithreading with Modern C++.
Modern C++ Concurrency in Depth ( C++17/20)
Functional Programming with Java and Threads
Modern Robotics, Course 1: Foundations of Robot Motion
Create Your First Multithreaded Application in Java
Introduction to Pointers and Memory Management in C/C++
API in C#: The Best Practices of Design and Implementation
401: Operating Syste
Beginning C++ Programming - From Beginner to Beyond
Hacking Unity and WatchKit - Make Games and Apple Watch...
Our mission

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.

Affiliate disclosure

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.

© 2016 - 2024 OpenCourser