Question 15
Back to Exercise
Where should lock.unlock() be called?
- A At the end of the method
- B In a finally block after lock(), so the lock is released even if an exception occurs Correct
- C Before lock()
- D It is not needed
Correct Answer: Option B
Unlike synchronized, explicit locks are not released automatically.
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!