LearnFrenzy
Sign in Take a free test

Multithreading · Multithreading MCQ · Question 9

What is a deadlock? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links