Interface ResourceLock
- All Superinterfaces:
AutoCloseable
A lock for a one or more resources.
- Since:
- 1.3
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionacquire()Acquire this resource lock, potentially blocking.default voidclose()Returns the exclusive resources this lock represents.default booleanisCompatible(ResourceLock other) Returns whether the given lock is compatible with this lock.booleanReturns whether this lock requires exclusiveness.voidrelease()Release this resource lock.
-
Method Details
-
acquire
Acquire this resource lock, potentially blocking.- Returns:
- this lock so it can easily be used in a try-with-resources statement.
- Throws:
InterruptedException- if the calling thread is interrupted while waiting to acquire this lock
-
release
void release()Release this resource lock. -
close
default void close()- Specified by:
closein interfaceAutoCloseable
-
getResources
List<ExclusiveResource> getResources()Returns the exclusive resources this lock represents.- Returns:
- the exclusive resources this lock represents
-
isExclusive
boolean isExclusive()Returns whether this lock requires exclusiveness.- Returns:
- whether this lock requires exclusiveness
-
isCompatible
Returns whether the given lock is compatible with this lock.- Parameters:
other- the other lock to check for compatibility- Returns:
- whether the given lock is compatible with this lock
-