ReentrantReadWriteLock.ReentrantWriteLock.TryLock Method

Definition

Overloads

TryLock()

Acquires the write lock only if it is not held by another thread at the time of invocation.

TryLock(Int64, TimeUnit)

Acquires the write lock if it is not held by another thread within the given waiting time and the current thread has not been Interrupt().

TryLock()

Acquires the write lock only if it is not held by another thread at the time of invocation.

[Android.Runtime.Register("tryLock", "()Z", "GetTryLockHandler")]
public virtual bool TryLock ();
[<Android.Runtime.Register("tryLock", "()Z", "GetTryLockHandler")>]
abstract member TryLock : unit -> bool
override this.TryLock : unit -> bool

Returns

Boolean

Implements

Attributes

Remarks

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

TryLock(Int64, TimeUnit)

Acquires the write lock if it is not held by another thread within the given waiting time and the current thread has not been Interrupt().

[Android.Runtime.Register("tryLock", "(JLjava/util/concurrent/TimeUnit;)Z", "GetTryLock_JLjava_util_concurrent_TimeUnit_Handler")]
public virtual bool TryLock (long timeout, Java.Util.Concurrent.TimeUnit? unit);
[<Android.Runtime.Register("tryLock", "(JLjava/util/concurrent/TimeUnit;)Z", "GetTryLock_JLjava_util_concurrent_TimeUnit_Handler")>]
abstract member TryLock : int64 * Java.Util.Concurrent.TimeUnit -> bool
override this.TryLock : int64 * Java.Util.Concurrent.TimeUnit -> bool

Parameters

timeout
Int64

the time to wait for the write lock

unit
TimeUnit

the time unit of the timeout argument

Returns

Boolean

Implements

Attributes

Exceptions

if the current thread is interrupted

if the time unit is null

Remarks

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