Skip to content

flash-thread-pool 当没有可消费的任务时会释放核心线程 #1

Description

@mapingfan

学习代码时候发现,

        // 阻塞地从队列里获取一个任务
        private Runnable getTask() {
            boolean timed = workCount.get() > corePoolSize;
            try {
                return timed ? workQueue.poll(keepAliveTime, timeUnit) : workQueue.take();
            } catch (InterruptedException e) {
                return null;
            }
        }

这段代码可能会导致所有工作线程因为取不到任务,然后退出

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions