Java Thread何时到达'Die'状态 [英] When does a Java Thread reach the 'Die' State

查看:116
本文介绍了Java Thread何时到达'Die'状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,Die是线程上的状态之一。

In Java, Die is one of the states on a thread.

是什么原因导致线程进入此状态?

What causes a thread to enter this state?

推荐答案

来自 Thread API ,这里有一个完整的列表:

From the Thread API, here is a complete list:


  • 如果run()方法返回。

  • 如果抛出的异常超出run方法传播。

  • 如果是守护程序线程并且所有非守护程序线程都死

  • 如果已调用类Runtime的exit方法(即使在另一个线程)。

  • If the run() method returns.
  • If an exception is thrown that propagates beyond the run method.
  • If it is a daemon thread and all non-daemon threads have 'died'
  • If the exit method of class Runtime has been called (even at another thread).

这篇关于Java Thread何时到达'Die'状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆