Package dev.enola.common
Class ShutdownCloser
java.lang.Object
dev.enola.common.ShutdownCloser
A utility class for gracefully closing resources (AutoCloseable instances) when the Java Virtual
Machine (JVM) shuts down. Typically used in main() methods to ensure that all resources are
closed when the application is terminated with Ctrl+C or a kill signal (which will not run
try-with-resources).
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidadd(AutoCloseable resource) Adds an AutoCloseable resource to the static set for graceful shutdown.
-
Method Details
-
add
Adds an AutoCloseable resource to the static set for graceful shutdown.- Parameters:
resource- The resource to be closed on JVM shutdown.
-