1. private boolean addWorker(Runnable firstTask, boolean core) {
    2. // 定义一个标签
    3. retry:
    4. for (;;) {
    5. int c = ctl.get();
    6. int rs = runStateOf(c);
    7. // Check if queue empty only if necessary.
    8. if (rs >= SHUTDOWN &&
    9. ! (rs == SHUTDOWN &&
    10. firstTask == null &&
    11. ! workQueue.isEmpty()))
    12. return false;
    13. for (;;) {
    14. int wc = workerCountOf(c);
    15. if (wc >= CAPACITY ||
    16. wc >= (core ? corePoolSize : maximumPoolSize))
    17. return false;
    18. if (compareAndIncrementWorkerCount(c))
    19. // 这里循环出来
    20. break retry;
    21. c = ctl.get(); // Re-read ctl
    22. if (runStateOf(c) != rs)
    23. // 这里走到标签那里
    24. continue retry;
    25. // else CAS failed due to workerCount change; retry inner loop
    26. }
    27. }
    28. ...
    29. }