Hi, I am having lot of CPU and IO intensive code in shutdown hook. Some times I see they are not getting executed properly. So Is there any limitation like we should not have lot of code in shutdown hook.
Thanks D. L. Kumar
Hi, I am having lot of CPU and IO intensive code in shutdown hook. Some times I see they are not getting executed properly. So Is there any limitation like we should not have lot of code in shutdown hook.
Thanks D. L. Kumar
Shutdown hooks are not guaranteed to run. Process abortion by kill
ing the process or hardware failures are typical cases when shutdown hooks are not run.
I have placed some fairly substantial code in a shutdown hook for one of my apps, and it executes very reliably on a variety of O/S's (Windows XP, Vista, AS400/iSeries/Systemi, Linux) under a variety of circumstances, including sigterms and Windows shutdown.
But beware of any system's shutdown timeout (ala Windows good ol' this program is not responding dialog).
Also beware true O/S kill commands, like Linux sigkill (?) and Windows task manager's end process.
Simply No. Read carefully API and you will see. There is limited time to shutdown. If you extend over this time slot the JVM will simply end/terminate without notification. If you are writing data, you will write down corrupted data.