Sdílet prostřednictvím


StampedLock.TryReadLock Method

Definition

Overloads

TryReadLock()

Non-exclusively acquires the lock if it is immediately available.

TryReadLock(Int64, TimeUnit)

Non-exclusively acquires the lock if it is available within the given time and the current thread has not been interrupted.

TryReadLock()

Non-exclusively acquires the lock if it is immediately available.

[Android.Runtime.Register("tryReadLock", "()J", "GetTryReadLockHandler", ApiSince=24)]
public virtual long TryReadLock ();
[<Android.Runtime.Register("tryReadLock", "()J", "GetTryReadLockHandler", ApiSince=24)>]
abstract member TryReadLock : unit -> int64
override this.TryReadLock : unit -> int64

Returns

a read stamp that can be used to unlock or convert mode, or zero if the lock is not available

Attributes

Remarks

Non-exclusively acquires the lock if it is immediately available.

Java documentation for java.util.concurrent.locks.StampedLock.tryReadLock().

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

TryReadLock(Int64, TimeUnit)

Non-exclusively acquires the lock if it is available within the given time and the current thread has not been interrupted.

[Android.Runtime.Register("tryReadLock", "(JLjava/util/concurrent/TimeUnit;)J", "GetTryReadLock_JLjava_util_concurrent_TimeUnit_Handler", ApiSince=24)]
public virtual long TryReadLock (long time, Java.Util.Concurrent.TimeUnit? unit);
[<Android.Runtime.Register("tryReadLock", "(JLjava/util/concurrent/TimeUnit;)J", "GetTryReadLock_JLjava_util_concurrent_TimeUnit_Handler", ApiSince=24)>]
abstract member TryReadLock : int64 * Java.Util.Concurrent.TimeUnit -> int64
override this.TryReadLock : int64 * Java.Util.Concurrent.TimeUnit -> int64

Parameters

time
Int64

the maximum time to wait for the lock

unit
TimeUnit

the time unit of the time argument

Returns

a read stamp that can be used to unlock or convert mode, or zero if the lock is not available

Attributes

Remarks

Non-exclusively acquires the lock if it is available within the given time and the current thread has not been interrupted. Behavior under timeout and interruption matches that specified for method Lock#tryLock(long,TimeUnit).

Java documentation for java.util.concurrent.locks.StampedLock.tryReadLock(long, java.util.concurrent.TimeUnit).

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