Skip to content
Sharp

Concurrency basics · interview question

What potential issue can ReentrantLock help solve compared to synchronized blocks?

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

Correct answer

B. Timeout handling

Why

ReentrantLock provides the tryLock() method with a timeout, allowing a thread to wait for a lock for a specified amount of time. This helps avoid indefinite blocking, which cannot be achieved with synchronized blocks.

Test yourself on Concurrency basics

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

Start free test
All Concurrency basics questions →