File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Is Shutdown Hook Guaranteed to be called? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Is Shutdown Hook Guaranteed to be called?" Watch "Is Shutdown Hook Guaranteed to be called?" New topic
Author

Is Shutdown Hook Guaranteed to be called?

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
If I add a shutdown hook, is it guaranteed to be called on all OS's? And what is the execution rule for this? Say for example, that I created an app that can run other aps inside it. It needs a shutdown hook to capture any time that an app calls System.exit(). However, what if another app (or even that app) added a shutdown hook? Which gets called first? Is there a rule? Is there a way to ensure one is the "master" hook, or rather, the last called?
What about permissions? Are there permissions for adding the shutdown hook? Is it possible to trap what happens in another shutdown hook?
Vijayakumar Arya
Ranch Hand

Joined: Jan 27, 2003
Posts: 76
Hi,
Answers for all your questions and more is available in the Java documentation,

Please refer to the Javadocs for Runtime.addShutdownHook(Thread hook) for details.


Thanks,<p>Vijay<p>The Hand that gives, Gathers.
 
 
subject: Is Shutdown Hook Guaranteed to be called?
 
Threads others viewed
JBoss terminated unexpectedly
Always execute code
Not able to resume command promt after using swings
spring shut down hook
Logging in a Shutdown Hook
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com