老师这里的c = ctl.get();是什么意思,拿到的是线程池吗,如果是的话isRunning(c)这是判断线程池的状态吗
来源:3-10 线程池状态

树莓派是什么派
2021-09-04
public void execute(Runnable command) {
if (command == null)
throw new NullPointerException();
int c = ctl.get();
if (workerCountOf(c) < corePoolSize) {
if (addWorker(command, true))
return;
c = ctl.get();
}
if (isRunning(c) && workQueue.offer(command)) {
int recheck = ctl.get();
if (! isRunning(recheck) && remove(command))
reject(command);
else if (workerCountOf(recheck) == 0)
addWorker(null, false);
}
else if (!addWorker(command, false))
reject(command);
}
写回答
1回答
-
悟空
2021-09-04
拿到的是线程池控制状态,全称pool control state,对,isRunning(c)这是判断线程池的状态
00
相似问题