Blocking Issues

This lesson explains the challenges of blocking issues while using a condition variable in C++.

To make my point clear, you have to use a condition variable in combination with a predicate. If you don’t, your program may become a victim of a spurious wakeup or lost wakeup.

If you use a condition variable without a predicate, it may happen that the notifying thread sends its notification before the waiting thread is in the waiting state; Therefore, the waiting thread waits forever. This phenomenon is called a lost wakeup. Here is the program.

Get hands-on with 1200+ tech skills courses.