events - Calling function when program exits in java -


i save programs settings every time user exits program. need way call function when user quits program. how do that?

i using java 1.5.

you can add shutdown hook application doing following:

runtime.getruntime().addshutdownhook(new thread(new runnable() {     public void run() {         // want     } })); 

this equivalent having try {} {} block around entire program, , encompasses what's in block.

please note caveats though!


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -