当前位置:网站首页>主线程与守护线程
主线程与守护线程
2022-07-28 23:00:00 【51CTO】
默认情况下,Java 进程需要等待所有线程都运行结束,才会结束。有一种特殊的线程叫做守护线程,只要其它非守护线程运行结束了,即使守护线程的代码没有执行完,也会强制结束。
例:
输出
08:26:38.123 [main] c.TestDaemon - 开始运行...
08:26:38.213 [daemon] c.TestDaemon - 开始运行...
08:26:39.215 [main] c.TestDaemon - 运行结束...
注意
垃圾回收器线程就是一种守护线程。
Tomcat 中的 Acceptor 和 Poller 线程都是守护线程,所以 Tomcat 接收到 shutdown 命令后,不会等待它们处理完当前请求。
边栏推荐
- Dynamic programming problem (VII)
- 【esn】 学习回声状态网络
- [basic course of flight control development 8] crazy shell · open source formation uav-i2c (laser ranging)
- 16.偏差、方差、正则化、学习曲线对模型的影响
- PTA (daily question) 7-72 calculate the cumulative sum
- Outlier detection and open set identification (2)
- Dynamic programming problem (4)
- How to solve the problems of MQ message loss, duplication and backlog?
- How to solve the problem that the Oracle instance cannot be started
- Basic knowledge of PHP language (super detailed)
猜你喜欢
![[micro services ~nacos] Nacos service providers and service consumers](/img/b7/47ecd6979ccfeb270261681d6130be.png)
[micro services ~nacos] Nacos service providers and service consumers

Software designer - intermediate, exam summary

聊聊异步编程的 7 种实现方式

Dynamic programming problem (6)

Anomaly detection and unsupervised learning (2)

Use hutool tool class to operate excel with more empty Sheet1

Shell programming specifications and variables

PTA (daily question) 7-74 yesterday

Outlier detection and Gan network (1)

15.模型评估和选择问题
随机推荐
Statistical analysis of time series
PTA (daily question) 7-73 turning triangle
ORACLE not available如何解决
Api 接口优化的那些技巧
110 MySQL interview questions and answers (continuously updated)
Dynamic programming (V)
mysql时间按小时格式化_mysql时间格式化,按时间段查询的MySQL语句[通俗易懂]
手把手教你安装Latex(保姆级教程)
Dynamic programming problem (3)
The 30th day of question brushing
pnpm的安装与使用
Use hutool tool class to operate excel with more empty Sheet1
Outlier detection and open set identification (1)
MQ 消息丢失、重复、积压问题,如何解决?
【开发教程10】疯壳·开源蓝牙心率防水运动手环-蓝牙 BLE 收发
PTA (daily question) 7-77 encryption
Brief introduction to compressed sensing
"Food alliance ordering system"
armeabi-v7a架构(sv7a)
Common sparse basis and matlab code for compressed sensing