下面一直在while (true) 里面循环跑,DownFilingThread 也是一个多线程,我跟踪进去了 即使 DownFilingThread 跑完了,groupRaw.activeCount() 还是在在跑,怎么判断一下线程是否结束,线程里面套线程
public void downPending(String beginDate, String endDate)
throws DownLoadException {
ThreadGroup groupRaw = new ThreadGroup("threadRaw");
ThreadGroup groupStd = new ThreadGroup("threadRaw"); Thread threadRaw = new Thread(groupRaw, new DownFilingThread(beginDate,
endDate, "raw"));
threadRaw.start(); while (true) {
if (groupRaw.activeCount() == 0) {
break;
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} System.out.println("okokokokokokokokokokokokokokokokok");
}
public void downPending(String beginDate, String endDate)
throws DownLoadException {
ThreadGroup groupRaw = new ThreadGroup("threadRaw");
ThreadGroup groupStd = new ThreadGroup("threadRaw"); Thread threadRaw = new Thread(groupRaw, new DownFilingThread(beginDate,
endDate, "raw"));
threadRaw.start(); while (true) {
if (groupRaw.activeCount() == 0) {
break;
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} System.out.println("okokokokokokokokokokokokokokokokok");
}
不太明白LZ的具体需求
感觉while (true)可以改为while(flag)
flag用volatile声明,在你说的那个线程结束之前把flag置为false
或者使用BooleanLock完成同样的事情