Skip to content

Conversation

@hay211
Copy link

@hay211 hay211 commented Jan 13, 2026

ScheduledThreadPool 和 SingleThreadScheduledExecutor 也是可以创建任意数量的线程,不是因为DelayedWorkQueue,而且 默认容量是16

ScheduledThreadPool 和 SingleThreadScheduledExecutor 也是可以创建任意数量的线程,不是因为DelayedWorkQueue,而且        private static final int INITIAL_CAPACITY = 16;
        private RunnableScheduledFuture<?>[] queue =
            new RunnableScheduledFuture<?>[INITIAL_CAPACITY];DelayedWorkQueue的默认容量是16
@hay211
Copy link
Author

hay211 commented Jan 13, 2026

image

@Snailclimb
Copy link
Owner

image

虽然maximumPoolSize设置得很大,但因为队列无界,永远触发无法创建非核心线程的逻辑。DelayedWorkQueue的最初容量虽小,但却是无界扩容的。

@hay211 hay211 closed this Jan 14, 2026
@hay211 hay211 deleted the patch-1 branch January 14, 2026 01:51
@hay211
Copy link
Author

hay211 commented Jan 14, 2026

好的,明白了,感谢Guide的回答

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants