Partager via


ReentrantLock.Lock Method

Definition

Acquires the lock.

[Android.Runtime.Register("lock", "()V", "GetLockHandler")]
public virtual void Lock ();
[<Android.Runtime.Register("lock", "()V", "GetLockHandler")>]
abstract member Lock : unit -> unit
override this.Lock : unit -> unit

Implements

Attributes

Remarks

Acquires the lock.

Acquires the lock if it is not held by another thread and returns immediately, setting the lock hold count to one.

If the current thread already holds the lock then the hold count is incremented by one and the method returns immediately.

If the lock is held by another thread then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired, at which time the lock hold count is set to one.

Java documentation for java.util.concurrent.locks.ReentrantLock.lock().

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