StampedLock.TryWriteLock Method

Definition

Overloads

TryWriteLock()

Exclusively acquires the lock if it is immediately available.

TryWriteLock(Int64, TimeUnit)

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

TryWriteLock()

Exclusively acquires the lock if it is immediately available.

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

Returns

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

Attributes

Remarks

Exclusively acquires the lock if it is immediately available.

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

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

TryWriteLock(Int64, TimeUnit)

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

[Android.Runtime.Register("tryWriteLock", "(JLjava/util/concurrent/TimeUnit;)J", "GetTryWriteLock_JLjava_util_concurrent_TimeUnit_Handler", ApiSince=24)]
public virtual long TryWriteLock (long time, Java.Util.Concurrent.TimeUnit? unit);
[<Android.Runtime.Register("tryWriteLock", "(JLjava/util/concurrent/TimeUnit;)J", "GetTryWriteLock_JLjava_util_concurrent_TimeUnit_Handler", ApiSince=24)>]
abstract member TryWriteLock : int64 * Java.Util.Concurrent.TimeUnit -> int64
override this.TryWriteLock : 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 write stamp that can be used to unlock or convert mode, or zero if the lock is not available

Attributes

Remarks

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.tryWriteLock(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