add
public static void add(int slot,
boolean registerShutdownInProgress,
Runnable hook)
Add a new shutdown hook. Checks the shutdown state and the hook itself,
but does not do any security checks.
The registerShutdownInProgress parameter should be false except
registering the DeleteOnExitHook since the first file may
be added to the delete on exit list by the application shutdown
hooks.
- Parameters:
slot
- the slot in the shutdown hook array, whose element
will be invoked in order during shutdown
registerShutdownInProgress
- true to allow the hook
to be registered even if the shutdown is in progress.
hook
- the hook to be registered
- Throws:
IllegalStateException
- if registerShutdownInProgress is false and shutdown is in progress; or
if registerShutdownInProgress is true and the shutdown process
already passes the given slot