tryLock

abstract fun tryLock(owner: Any? = null): Boolean(source)

Tries to lock this mutex, returning false if this mutex is already locked.

It is recommended to use withLock for safety reasons, so that the acquired lock is always released at the end of your critical section, and unlock is never invoked before a successful lock acquisition.

Parameters

owner

Optional owner token for debugging. When owner is specified (non-null value) and this mutex is already locked with the same token (same identity), this function throws IllegalStateException.