Package org.onehippo.cms7.services.lock
Interface LockResource
-
- All Superinterfaces:
AutoCloseable
public interface LockResource extends AutoCloseable
The returned auto closeable object in case
LockManager.lock(String)
succeeds. A LockResource object can be shared across threads and is thread-safe
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Close theLockResource
and unlocks (removes) the lock.Thread
getHolder()
Lock
getLock()
boolean
isClosed()
boolean
isNewLock()
-
-
-
Method Detail
-
isClosed
boolean isClosed()
- Returns:
- true if this
LockResource
has been closed
-
close
void close()
Close theLockResource
and unlocks (removes) the lock.Note: unlike
LockManager.unlock(String)
this may be invoked by another thread, allowing delegation of unlocking the lock to another threadWarning: while the LockResource may be closed by another thread, the lock itself remains tied to the thread creating it!
Therefore the thread creating the lock must NOT be terminated before the other thread completes the process requiring the lock, as the lock then may expire prematurely!- Specified by:
close
in interfaceAutoCloseable
-
getLock
Lock getLock()
- Returns:
- the
Lock
for thsLockResource
-
isNewLock
boolean isNewLock()
- Returns:
- true if this
getLock()
was created together with thisLockResource
instance; false if thisgetLock()
already was created earlier by the same thread creating thisLockResource
.
-
getHolder
Thread getHolder()
- Returns:
- the
Thread
that holds thisLockResource
ornull
in case theThread
that created this lock has already stopped and been GC-ed
-
-