java - When is control CTRL+C ignored -


I have a Java application that has been implemented as a main method, with an end, the block Prevent this work is done within the effort if I kick the app through a Bash script, and during its execution a CTRL + C is released, then I am not seeing incompatible behavior ever - Any catch block is executed and sometimes it does not happen. Can it be explained?

(sample code below - where sometimes neither "caught" or "shutdown complete" are logged)

  public square fu {public static zero main string [ ] Args) {try {doStuff (}}} Catch (throbable e) {LOGGER.error ("caught", e); } Finally {LOGGER.info ("shutdown complete."); According to JVM, the end does not guarantee that the block is not executed: 

If JVM is being executed, try or hold the code, then the end block Can not be executed. Similarly, if the attempt or capture code is executed or killed, the thread is executed or killed, then the block can not be executed at all, even if the application continues in full form.

Thus you can not trust the block at the end. If you want to capture the CTRL-C event, you can make better use.


Comments