Quiz · Multithreading: An Overview · lesson 5 of 12
Quiz — where the mutex is released
Where, if anywhere, does the call add(-1) unlock the mutex m?
#include <mutex>
std::mutex m;
int total = 0;
void add(int x) {
std::lock_guard<std::mutex> guard(m);
if (x < 0) {
return;
}
total += x;
}Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.