Question 9
Back to Exercise
Thread A locks m1 then m2; thread B locks m2 then m1. What can happen?
- A Nothing – mutexes prevent problems
- B A deadlock: each holds one mutex and waits forever for the other Correct
- C A data race
- D The program runs faster
Correct Answer: Option B
Lock in one global order, or use std::scoped_lock(m1, m2).
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!