🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Multithreading: all 10 questions

Quiz: Java Multithreading · Question 9 of 10

Which rule prevents the classic two-lock deadlock?

Which rule prevents the classic two-lock deadlock?

  1. A.Use more threads
  2. B.Call sleep() before taking a lock
  3. C.Make every method static
  4. D.Always take the locks in the same order in every thread
Answer & explanation

Correct answer: Always take the locks in the same order in every thread

If every thread locks A before B, no thread can hold B while waiting for A, so the circular wait cannot form.

Can you get the rest right without peeking?

Take the timed Quiz: Java Multithreading quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →