tryLock()
Attempts to acquire the lock in a non-blocking manner.
Returns:
true if the lock was acquired successfully.
false if the lock could not be acquired immediately.
It does not wait for the lock to become available.
D is correct, you can read more about it here:
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html#tryLock--
the lock() method doesnt return anything, so A and B are wrong.
tryLock() always returns a boolean immediately, no waiting involved. returns True immediately if and only if the thread is available and successfully locked, otherwise false.
upvoted 3 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
SrinivasJasti
2 weeks, 2 days agosupersquax
5 months, 2 weeks ago