trueLife
trueLife

Reputation: 93

Calling shutDownHook for certain exit codes?

As far as I know System.exit triggers shutdown hook(if any hook registered) so while shutdown hook thread is waiting for any other thread to join if other thread calls System.exit() I think a deadlock occurs so is there any solution to register a shutdown hook for certain exit codes such as -1? By this way I can prevent a shutdown hook not to work for some specials exit situations. Thanks in advance.

Upvotes: 0

Views: 673

Answers (1)

Kenster
Kenster

Reputation: 25399

The shutdown hook mechanism doesn't have any way to run shutdown hooks just for particular exit codes. You could register a shutdown hook which checks the exit code, as discussed here, and decides what to do based on that.

Upvotes: 1

Related Questions