Abstract supertype of resources which may be obtained at
the beginning of a try statement and then released when
the statement completes. Unlike a Destroyable resource,
a single instance of Obtainable may be reused between
multiple try statements or multiple executions of the
same try statement.
Lock lock = ... ;
try (lock) {
...
}
obtain() is called before the body of the try
statement is executed, andrelease() is called when execution of the body of the
try statement ends, even if an exception propagates out
of the body of the try.A class which satisfies Obtainable may impose constraints
on the ordering and nesting of invocations of obtain()
and release(). For example, it may be not be possible to
obtain a resource that has already been obtained. Those
methods should produce an AssertionError when any such
constraint is violated.
Destroyableno type hierarchy
no subtypes hierarchy
| Methods | |
obtain | Source Codeshared formal void obtain()Obtain this resource. Called before the body of a If an exception is thrown by Throws
|
release | Source Codeshared formal void release(Throwable? error)Release this resource. Called when execution of the
body of a Parameters:
Throws
|
| Inherited Methods |
Methods inherited from: Object |