守护线程Daemon的理解
2024-09-06 06:17:22
1、守护线程伴随着主线程的销毁而销毁;
2、jvm虚拟机中有很多守护线程,随着main函数的结束而结束,自动回收栈中的内容。
Thread t1 = new Thread(){
@Override
public void run() {
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ad++;
System.out.println(ad);
}
}
};
t1.setDaemon(true);
t1.start();
Thread.sleep(2000);
System.out.println(ad);
最新文章
- 基于Dubbo框架构建分布式服务(一)
- [Unreal]学习笔记之灯光说明
- C#基础知识一之base关键字
- 【MySQL】Create table 以及 foreign key 删表顺序考究。
- 【Cocos2d-x游戏开发】Cocos2d-x中的弱联网技术
- Android 进程常驻----native保活5.0以下方案推演过程以及代码
- 数据库和3G的结合使用
- [MongDB] 主从架构--官方极力不推荐
- C#设计模式(11)——外观模式(Facade Pattern)
- javascript继承(一)—类的属性研究
- ZooKeeper 安装部署
- utf-8转换为ansi和修改文件名的批处理(可解决source insight中文注释乱码问题)
- Google DNS劫持背后的技术分析
- spring-mvc @Controller 200-不生效
- 【20171104中】chrome自动刷新网页
- memcpy一种实现方法
- js复习--基础
- Lombok轮子
- python 爬虫-2
- Terminating app due to uncaught exception &#39;NSInvalidArgumentException&#39;, reason: &#39;*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]&#39;
热门文章
- Cow Exhibition (01背包)
- 72.spring boot讨论群【从零开始学Spring Boot】
- [luoguP1266] 速度限制(spfa)
- Codeforces Round #292 (Div. 2) D. Drazil and Tiles [拓扑排序 dfs]
- 转: ORACLE存储过程笔记2----运算符和表达式
- 【TFS 2017 CI/CD系列 - 02】-- Build篇
- 在Studio中使用Access数据库时,提示“未在本地计算机上注册“Microsoft.ACE.OLEDB.12.0”提供程序”
- MySQL 资源大全
- Android系统改动时间格式为24小时制
- eclipse Alt+/ 不能提示