...
Wiki Markup |
---|
According to the Java API \[[API 062006|AA. Java References#API 06]\] Class {{Runtime}}, method {{addShutdownHook}}: |
...
- Hook threads should be light-weight and simple
- They should be thread safe
- They should hold locks when accessing data and release them when done
Wiki Markup They should not rely on system services as the services themselves may be shutting down (for example, the logger may shutdown from another hook). Instead of one service it may be better to run a series of shutdown tasks from one thread by using a single shutdown hook. \[[Goetz 062006|AA. Java References#Goetz 06]\]
...
Wiki Markup |
---|
*EX1:* It is permissible for a command line utility to call {{System.exit()}} or terminate prematurely, for example, when the required number of arguments are not input. \[[Bloch 082008|AA. Java References#Bloch 08]\] and \[[ESA 052005|AA. Java References#ESA 05]\] |
...
References
Wiki Markup |
---|
\[[API 062006|AA. Java References#API 06]\] [method checkExit()|http://java.sun.com/j2se/1.4.2/docs/api/java/lang/SecurityManager.html#checkExit(int)], Class Runtime, method addShutdownHook \[[Kalinovsky 042004|AA. Java References#Kalinovsky 04]\] Chapter 16 Intercepting a Call to System.exit \[[Austin 002000|AA. Java References#Austin 00]\] [Writing a Security Manager|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed2.html] \[[Darwin 042004|AA. Java References#Darwin 04]\] 9.5 The Finalize Method \[[Goetz 062006|AA. Java References#Goetz 06]\] 7.4. JVM Shutdown \[[ESA 052005|AA. Java References#ESA 05]\] Rule 78: Restrict the use of the System.exit method \[[MITRE 092009|AA. Java References#MITRE 09]\] [CWE ID 382|http://cwe.mitre.org/data/definitions/382.html] "J2EE Bad Practices: Use of System.exit()" |
...