- Enclosing class:
- ShutdownHook
public static interface ShutdownHook.Listener
Object that needs to cleanup on JVM shutdown.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Cleanup resources when JVM shuts down, called from JVM shutdown hook.
-
Method Details
-
onShutdown
void onShutdown()Cleanup resources when JVM shuts down, called from JVM shutdown hook.Implementations should be coded defensively
- they should finish their work quickly
- they should be written to be thread-safe and to avoid deadlocks insofar as possible
- they should not rely blindly upon services that may have registered their own shutdown hooks and therefore may themselves be in the process of shutting down
- attempts to use other thread-based services may lead to deadlocks.
Runtime.addShutdownHook(java.lang.Thread)
for more details.
-