老师这里的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)这是判断线程池的状态

0
0

深度解密Java并发工具,精通JUC,成为并发多面手

JUC全方位讲解,构建并发工具类知识体系

1599 学习 · 573 问题

查看课程