Worker
public void run() {
runWorker(this);
}
while (task != null || (task = getTask()) != null) {
Runnable r = timed ?
workQueue.poll(keepAliveTime, TimeUnit.NANOSECONDS) :
workQueue.take();
if (r != null)
return r;
添加工作线程并启动后,工作线程不段的从队列获取任务,
当超时获取不到任务,超时标志设置为true, 下一次循环判断超时,返回null,
则跳出工作循环,执行 processWorkerExit(w, completedAbruptly);
打断空闲线程 interruptIdleWorkers t.interrupt();
最后
以上就是留胡子硬币最近收集整理的关于ThreadPoolExecutor 如何判断空闲线程的全部内容,更多相关ThreadPoolExecutor内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复