Skip to content
Sharp

Concurrency basics · interview question

Which of the following statements about lock fairness in ReentrantLock is true?

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

Correct answer

B. Fair mode reduces throughput by ensuring first-come-first-serve

Why

ReentrantLock can be instantiated in fair mode, which ensures that threads acquire locks in the order they are requested. However, this can reduce throughput as it might lead to more context switching, making it less efficient than the default unfair mode.

Test yourself on Concurrency basics

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

Start free test
All Concurrency basics questions →