C++ Multi Threading Part 2: Mutex And Conditional Variables

Опубликовано: 22 Февраль 2026
на канале: arisaif
26,834
825

I explain what a mutex is and how to use it in modern C++. Also, I explain what a conditional variable in C++ is and how to use it.

I cover the following topics:

Race condition
Mutual exclusion in modern C++
std::mutex
lock() / unlock()
lock_guard
unique_lock
shared_lock
scoped_lock
Sequential Consistency
Deadlock
Thread communication with Conditional Variables

I use modern C++11, C++14, and C++17 constructs.

This is my second video on C++ Multithreading.
Link to Part 1:    • Learn C++ Multi Threading in 20 Minutes  

You can download and code with me using this link:
https://github.com/ourarash/multithre...

You can run the code either using Bazel or gcc/g++.

Check my other video on using Bazel to build C++ files in Visual Studio Code:

   • Bazel & Google Test in Visual Studio Code  

More details on Bazel:
https://github.com/ourarash/cpp-template

------------------------------------------------------------------------------------------
Keep in touch with me:
  / ourarash  

I'm the founder of BitcoinCrazyness app, the Most Advanced Cryptocurrency APP, Check it out:

http://www.bitcoincrazyness.com/