public class Exit
extends java.lang.Object
boolean isExit = addExit(); try { ... } finally { if (isExit) exit(); }
Objects register for the exit callback by calling
addExit(listener, object)
.
Exits are intrinsically tied to a thread.
Modifier and Type | Method and Description |
---|---|
static boolean |
addExit()
Starts a protection scope.
|
static void |
addExit(ExitListener listener,
java.lang.Object object)
Registers the object and listener.
|
static void |
exit()
Calls all registered listeners.
|
public static void addExit(ExitListener listener, java.lang.Object object)
If there is no protection scope, i.e. addExit() hasn't been called, then this function does nothing.
listener
- the exit handlerobject
- the object which needs cleanuppublic static boolean addExit()
public static void exit()