Friday, March 20, 2009

Java and Shutdown

you can add a shutdown handler:

Runtime.getRuntime().addShutdownHook(sh);

where sh is a Thread

Problem is, in Unix it works only with CTRL-C, not witk kill -9 or kill -8 (abort).

In Windows, if I terminate my JVM with Eclipse's "terminate" button, the hook is not executed.


No comments: