What Happens If a Thread Can't Get the Lock in java?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 24, 2014, 5:55 AM EDT
However, you can use the tryLock() method which does not wait if the lock is unavailable. Instead it returns true if the lock is acquired (and proceeds accordingly) or false otherwise.
Abhijeet SinghRank #415 · 6K reputationPosted Mar 28, 2014, 9:51 AM EDT