Hi, If I have a Java process running and I terminate the JVM through the Unix console (kill -9 <<process id>> , can I still manage to trigger some process before the Java application stops? I would like to trigger the process through Java programmatically.
best regards,<br />Steven<br />SCJP, SCEA
posted 14 years ago
Take a look at Runtime.addShutdownHook(Thread hook). Be sure to read thru the caveats listed in tha API docs. The hook must do its work quickly and be thread-safe and avoid deadlocks.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher