mysql5.7和8.0的区别_System.exit(-1)与System.exit(0)及System.exit(1)的含义与区别

ca0a1decabdfc697297ec650df24f047.png

以下System.exti(int status)源码

/** * Terminates the currently running Java Virtual Machine. The * argument serves as a status code; by convention, a nonzero status * code indicates abnormal termination. * 

* This method calls the exit method in class * Runtime. This method never returns normally. *

* The call System.exit(n) is effectively equivalent to * the call: *

 * Runtime.getRuntime().exit(n) * 
* * @param status exit status. * @throws SecurityException * if a security manager exists and its checkExit * method doesn't allow exit with the specified status. * @see java.lang.Runtime#exit(int) */public static void exit(int status) { Runtime.getRuntime().exit(status);}

1、System.exit(status)不管status为何值都会退出程序,终止当前正在运行的 Java 虚拟机,将JVM其中所有的内容都停掉。参数status用作状态码,非零的状态码表示异常终止。

2、System.exit(-1)、System.exit(1)是非正常退出,就是说无论程序正在执行与否,都退出。

3、System.exit(0)是正常退出,程序正常执行结束退出。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值