Skip to content
Sharp

Concurrency basics · interview question

What does trying to acquire a lock using ReentrantLock's tryLock() method if the lock is not available evaluate to?

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

Correct answer

A. The method returns false.

Why

The tryLock() method attempts to acquire the lock immediately, and if the lock is not available, it returns false without blocking the thread.

Test yourself on Concurrency basics

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

Start free test
All Concurrency basics questions →