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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -