Java守护线程(Java Daemon)

本文深入探讨了Java中守护线程的概念与作用。从Java虚拟机启动时的默认线程开始,介绍了守护线程如何影响Java虚拟机的运行与终止过程。当所有非守护线程结束,Java虚拟机将随之关闭。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 


Java version 1.8.0_131


Java源码中关于守护线程(Daemon)的介绍

// ... ...

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.

// ... ...

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值