private boolean addWorker(Runnable firstTask, boolean core) {
// 定义一个标签
retry:
for (;;) {
int c = ctl.get();
int rs = runStateOf(c);
// Check if queue empty only if necessary.
if (rs >= SHUTDOWN &&
! (rs == SHUTDOWN &&
firstTask == null &&
! workQueue.isEmpty()))
return false;
for (;;) {
int wc = workerCountOf(c);
if (wc >= CAPACITY ||
wc >= (core ? corePoolSize : maximumPoolSize))
return false;
if (compareAndIncrementWorkerCount(c))
// 这里循环出来
break retry;
c = ctl.get(); // Re-read ctl
if (runStateOf(c) != rs)
// 这里走到标签那里
continue retry;
// else CAS failed due to workerCount change; retry inner loop
}
}
...
}