Interface Pooled<E>
- Type Parameters:
E- The type of the wrapped object.
- All Superinterfaces:
AutoCloseable
The
Pooled interface represents a wrapper around an object that can
be returned to a pool after use.
Pooled objects are AutoCloseable for convenience, e.g. usage
in try-with-resources statements.
- Since:
- 1.8
-
Method Summary
-
Method Details
-
get
E get()Retrieves the underlying object managed by thisPooledinstance.- Returns:
- The object of type
E.
-
free
void free()Returns the object back to the pool, making it available for reuse.Either this method or, equivalently,
close()should be called when the object is no longer needed by the caller.Do not call this method multiple times. That also means you should call either free or close, never both. Implementations may detect this and throw some exception, but can typically not do that reliably.
-
close
default void close()Equivalent tofree()for convenience.- Specified by:
closein interfaceAutoCloseable
-