Skip to content
Sharp

Concurrency basics · interview question

In a system using multiple ReentrantLocks, how can you minimize the risk of deadlocks?

Multiple choiceHardchapter-15-curatedpremiumconcurrencysynchronized-and-locks
Choose one answer
Answer and explanation

Correct answer

A. Ensure locks are acquired in a consistent order

Why

Deadlocks often occur due to inconsistent lock acquisition order. Ensuring that all threads acquire multiple locks in the same order can prevent circular waiting conditions, thereby reducing the risk of deadlocks.

Test yourself on Concurrency basics

A free test with instant, explained results. No account needed.

Start free test
All Concurrency basics questions →