LearnFrenzy
Sign in Take a free test

Concurrency and Executors · Concurrency and Executors MCQ · Question 16

The benefit of tryLock Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 16 Back to Exercise

What does lock.tryLock(1, TimeUnit.SECONDS) allow?

  • A Locking twice
  • B Giving up if the lock is not available within a second – useful to avoid deadlock Correct
  • C Unlocking automatically
  • D Reading without locking
Correct Answer: Option B

It returns true if the lock was acquired.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links