Java.Util.Concurrent.Locks.ReentrantLock.HoldCount Property
Queries the number of holds on this lock by the current thread.

Syntax

[get: Android.Runtime.Register("getHoldCount", "()I", "GetGetHoldCountHandler")]
public virtual int HoldCount { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Queries the number of holds on this lock by the current thread.

A thread has a hold on a lock for each lock action that is not matched by an unlock action.

The hold count information is typically only used for testing and debugging purposes. For example, if a certain section of code should not be entered with the lock already held then we can assert that fact:

java Example

class X {
   ReentrantLock lock = new ReentrantLock();
   // ...
   public void m() {
     assert lock.getHoldCount() == 0;
     lock.lock();
     try {
       // ... method body
      finally {
       lock.unlock();
     }
   }
 }}

[Android Documentation]

Requirements

Namespace: Java.Util.Concurrent.Locks
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1