Dec
17
Filed Under (Life) by Thejesh GN on 17-12-2007

Simple shutdown hooks can often be written as anonymous inner classes, as in this example:


Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() { call_ur_method(); }
});

This idiom is fine as long as you’ll never need to cancel the hook, in which case you’d need to save a reference to the hook when you create it.

More about Java Application shutdown hook design



Post a comment
Name: 
Email: 
URL: 
Comments: