What happens if System.exit is called from a shutdown hook?
问题 I have a rather complicated shutdown in Java - there's a lot of clean up work to do. In particular I'm trying to figure out how to error handle from a shutdown hook thread. My code includes this currently: try { return shutdownPromise = doShutdown(); } catch (Throwable exc) { logger.error("An exception was thrown while shutting down the application.", exc); System.exit(1); return null; } When I originally wrote this I essentially thought, an error in shutdown should just go straight to exit .