# Interface: com.pnfsoftware.jeb.core.units.IUnitLock

Definition of a unit model lock. Unit locks are optionally provided by [units](IUnit).

## Method: a
- return type: `com.pnfsoftware.jeb.util.concurrent.ACLock`

Description: Attempt to acquire an auto\-closable wrapper on this unit lock. If the lock cannot be acquired within the time frame defined by [#getDefaultBlockTimeoutMs()](#getDefaultBlockTimeoutMs()), it will throw a [UnitLockedException](UnitLockedException) \(see [#getDefaultBlockTimeoutMs()](#getDefaultBlockTimeoutMs())\). 

 Best\-practice: This method must be called in a try\-with\-resources.
return: an auto\-closeable lock handle

## Method: a
- parameter: `blockTimeoutMs`, type: `long`
- return type: `com.pnfsoftware.jeb.util.concurrent.ACLock`

Description: Attempt to acquire an auto\-closable wrapper on this unit lock. If the lock cannot be acquired within the provided time frame, the method will throw a [UnitLockedException](UnitLockedException) \(see [#getDefaultBlockTimeoutMs()](#getDefaultBlockTimeoutMs())\). 

 Best\-practice: This method must be called in a try\-with\-resources.
parameter: blockTimeoutMs: timeout in milliseconds
return: an auto\-closeable lock handle

## Method: getDefaultBlockTimeoutMs
- return type: `long`

Description: Get the default wait time lock acquisition will block before throwing a [UnitLockedException](UnitLockedException).
return: the allowed max blocking time; 0 means never fail \(ie, fail if the lock is held by         another thread\); `<0` means wait indefinitely

## Method: isLocked
- return type: `boolean`

Description: Determine if the lock is held by \_any\_ thread. Purely indicative, do not use for synchronization.
return: true if the lock is held

## Method: isLockedByCurrentThread
- return type: `boolean`

Description: Determine if the lock is held by \_this\_ thread. Purely indicative, do not use for synchronization.
return: true if the lock is held by the current thread

## Method: verifyLocked

Description: Verify that the lock is help by this thread, and raise an exception if not.
throws: if the lock is not owned by the calling thread

