Shutdown Hooks

JVM shutdown hooks are always called during the JVM shutdown sequence. An application should use either shutdown hooks or component notifiers (see Chapter 11, Components) to cleanly terminate an application.

It is legal to do transactional work in a shutdown hook. During JVM shutdown, a shutdown hook that is not in a transaction will not prevent the JVM from shutting down cleanly if it does not complete before other JVM shutdown tasks complete.