System.exit(num) or throw a RuntimeException from main?

前端 未结 7 1809
日久生厌
日久生厌 2020-12-18 19:57

I\'ve got a single threaded app that should set the DOS errorlevel to something non-zero if there is a problem. Is it better to throw a RuntimeException, or to use System.ex

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-18 20:20

    System.exit(num) is not a good option, as its shutdown JVM, plus even it didnt run the finally block if you have after catch block.

    Throwing RuntimeException also might not be the best of the option, can subclass as mentioned earlier which is app specific exception could be a better option in my opinion. -Manish

提交回复
热议问题