Java shutdown hook call on windows shut down -


i have situation in want perform task when user signals os(in case windows) shutdown.

i have tried using java shutdown hooks. problem face when exit program using system.exit(0);, shutdown hooks called when directly shutdown computer, aren't.

this code have used shutdown hooks-

runtime.getruntime().addshutdownhook(new jvmshutdownhook()); //in main method  //within main java class private static class jvmshutdownhook extends thread { @override public void run() {    //perform tasks } } 

is there way interact os(i'm assuming native code) allows program exit gracefully?

any appreciated.

shutdownhooks indeed not work shutdown of windows. consider bug of java , opened bugreport last week. has not (yet) been published.

there old bug report in 2008: runtime#addshutdownhook not work on windows vista, when user logs out. same problem occurs windows 7. ticket closed java.com without satifying response.

windows gives shutdown time applications terminate gracefully. delay defined registry key waittokillapplication. expect java program uses delay execute hooks (and finalizes if runtime.runfinalizersonexit() set).

let see if oracle recognizes bug...


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

amazon web services - Installing MobileFirst 7.0 server on AWS -

Non Unique Username with ASP.Net Identity 2.0 -