Package org.aesh.terminal.tty.utils
Class ShutdownHooks
java.lang.Object
org.aesh.terminal.tty.utils.ShutdownHooks
Manages the shutdown-hook thread and tasks to execute on shutdown.
- Author:
- Jason Dillon
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA task that can be executed on shutdown. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends ShutdownHooks.Task>
Tadd(T task) Adds a task to be executed on JVM shutdown.static voidremove(ShutdownHooks.Task task) Removes a task from the shutdown hook.
-
Method Details
-
add
Adds a task to be executed on JVM shutdown. If this is the first task, a shutdown hook thread is registered.- Type Parameters:
T- the task type- Parameters:
task- the task to execute on shutdown- Returns:
- the task that was added
-
remove
Removes a task from the shutdown hook. If no tasks remain, the shutdown hook thread is unregistered.- Parameters:
task- the task to remove
-