0

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.

kirti
  • 4,499
  • 4
  • 31
  • 60
trueLife
  • 103
  • 7
  • 1
    possible duplicate of [Determine exit status within the java shutdown hook thread](http://stackoverflow.com/questions/1486679/determine-exit-status-within-the-java-shutdown-hook-thread) – Kenster Oct 31 '14 at 19:16

1 Answers1

1

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.

Community
  • 1
  • 1
Kenster
  • 23,465
  • 21
  • 80
  • 106