public interface Destroyable
This interface adds "destruction" context to an implementing class. Any instance of the class may now be in "pre-destroyed" (working) state or "destroyed" state. And it may be called to destroy itself to clean up after performing some work.
destroy(),
isDestroyed(),
AbstractDestroyable| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
This method may be called to ask instance to release any locked resources
and to prepare itself to be properly garbage collected.
|
boolean |
isDestroyed()
This method returns
true if this instance was already destroyed and cannot be used anymore. |
void destroy()
This method may be called to ask instance to release any locked resources and to prepare itself to be properly garbage collected.
Note: this method should not throw an exception for being called for the second (or more) time. If instance is already destroyed - method should exit without performing any actual functionality.
boolean isDestroyed()
This method returns true if this instance was already destroyed and cannot be used anymore.
If this method returns true - it is a signal for other parts of the program to not perform any
additional calls on it.
If this method returns false - destroy() should be called when instance is not planned
to be used anymore.