惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - 飞翔

杂记 VI使用技巧 浮躁,太浮躁了 有空看看的一些技术文章 工作流概述 JavaMail 应用 - 飞翔 - 博客园 权限系统概要 --转 看的的有意思的帖子收集 动态编译JAVA程序 Log4j基本使用方法 dom4j 读取xml文件时遇到的怪问题(org.dom4j.DocumentException: no protocol) spring+hibernate 处理oracle clob (编辑中) Oracle插入大量文字 Struts menu的使用(动态数据) 网页 的一些信息 - 飞翔 - 博客园 Struts Validator验证器使用指南 错误汇总 谈IFRAME标签的使用 appfuse 杂记 - 飞翔 - 博客园
多线程 Thread 学习杂记
飞翔 · 2005-10-10 · via 博客园 - 飞翔

1.   判断所有线程已经结束
可以使用线程等待结束的方法:
List threadList = new ArrayList();
for (int j = 0; j < 100; ++j)
{

GetHttpThread t = new GetHttpThread(urlList.get(j).toString());
t.start();
threadList.add(t);
}

for(int i=0;i<threadList.size();i++){
 Thread t = (Thread)threadList.get(i);
 t.join();
}
这样,每一个join都会等待该线程结束。当下面那个循环执行完的时候,那么所有线程就都结束了。

还有一个方法就是利用回调。每一个执行线程在run方法的最后都去回调主线程的一个计数器方法。