Shutdown hook for a clean shutdown
There's a good chance that some non-daemon threads handled by some sort of
ExecutorService
are preventing JVM from a clean shutdown.
How to use it exactly depends on the situation.
For example when dealing a simple Java "main" program, which has only a single context then
registering this hook by
Runtime.addShutdownHook(Thread)
should be sufficient.
In case of some sort of webapp in a servlet container where there are multiple levels of contexts
the recommended way to use it is to register a
javax.servlet.ServletContextListener
and call
run()
method inside
javax.servlet.ServletContextListener#contextDestroyed(ServletContextEvent)
NB! As the usage method of this hook is dependant on the system/situation and may vary,
so in consequence it's still in experimental status
Created by Janar Rahumeel (CGI Estonia)