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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -