Attempts to acquire in exclusive mode, aborting if interrupted,
and failing if the given timeout elapses.
Attempts to acquire in exclusive mode, aborting if interrupted,
and failing if the given timeout elapses. Implemented by first
checking interrupt status, then invoking at least once
AbstractQueuedLongSynchronizer.tryAcquire(long)
, returning on success. Otherwise, the thread is
queued, possibly repeatedly blocking and unblocking, invoking
AbstractQueuedLongSynchronizer.tryAcquire(long)
until success or the thread is interrupted
or the timeout elapses. This method can be used to implement
method
Lock.tryLock(long, TimeUnit)
.
Returns:
{@code true} if acquired; {@code false} if timed out
Parameters:
-
arg - the acquire argument. This value is conveyed to
{@link #tryAcquire} but is otherwise uninterpreted and
can represent anything you like.
-
nanosTimeout - the maximum number of nanoseconds to wait
Throws:
-
InterruptedException - if the current thread is interrupted