multithreading - How can I detect when my standalone Java application was shut down? -
i have standalone java application acts consumer connects activemq queue. in application's main()
method, create instance of consumer thread , start it.
seeing i'm using jms this, want add shutdown hook application when application stops working (either terminated or killed), application run method wherein resources closed.
i tried runtime.addshutdownhook()
doesn't seem invoked whenever shut down application.
i act if contextdestroyed()
method of servletcontextlistener
invoked.
runtime.addshutdownhook()
correct api use, unfortunately "stop" button in eclipse terminates process without allowing hooks run. see shutdown hook doesn't work in eclipse more information.
Comments
Post a Comment