次の方法で共有


AbstractQueuedSynchronizer.TryAcquireNanos(Int32, Int64) Method

Definition

Attempts to acquire in exclusive mode, aborting if interrupted, and failing if the given timeout elapses.

[Android.Runtime.Register("tryAcquireNanos", "(IJ)Z", "")]
public bool TryAcquireNanos (int arg, long nanosTimeout);
[<Android.Runtime.Register("tryAcquireNanos", "(IJ)Z", "")>]
member this.TryAcquireNanos : int * int64 -> bool

Parameters

arg
Int32

the acquire argument. This value is conveyed to #tryAcquire but is otherwise uninterpreted and can represent anything you like.

nanosTimeout
Int64

the maximum number of nanoseconds to wait

Returns

true if acquired; false if timed out

Attributes

Exceptions

if the current thread is interrupted

Remarks

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 #tryAcquire, returning on success. Otherwise, the thread is queued, possibly repeatedly blocking and unblocking, invoking #tryAcquire until success or the thread is interrupted or the timeout elapses. This method can be used to implement method Lock#tryLock(long, TimeUnit).

Java documentation for java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireNanos(int, long).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to