Java 之 线程/JVM退出

Thread 退出条件

  • run 方法执行完毕
  • run 方法抛异常

JVM 退出条件

  • When a Java Virtual Machine starts up, there is usually a single non-daemon thread (which typically calls the method named main of some designated class). The Java Virtual Machine continues to execute threads until either of the following occurs:
    • The exit method of class Runtime has been called and the security manager has permitted the exit operation to take place.
    • All threads that are not daemon threads have died, either by returning from the call to the run method or by throwing an exception that propagates beyond the run method.
  • 当没有用户线程执行的时候
  • 在任何线程调用 System.exit 会导致退出
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,418评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,786评论 0 23
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,718评论 0 3
  • 时间过得太快了,快到我都来不及去好好的看一看这来路的好风景,就已经错过了许多。 很奇怪,在公交上的时候往往最能静心...
    初安耶阅读 146评论 0 2
  • 周二那天出差,刚一上车,就看见靠窗的座位上坐着的女人正喜笑颜开的对着手机聊语音,我出示车票示意她说那是我的座...
    簌簌主播阅读 1,131评论 3 4