How do corePoolSize, maxPoolSize, the queue and rejection policy interact in ThreadPoolExecutor?
⚡ Short Answer
Tasks first fill core threads, THEN the queue, and only when the queue is full are threads grown to max — finally the RejectedExecutionHandler fires. A common surprise: with an unbounded queue, max is never reached because the queue never fills.
☕Coffee Chat Question
Concept Made Simple
“How do corePoolSize, maxPoolSize, the queue and rejection policy interact in ThreadPoolExecutor?”
🧠Mind Map Answer
Remember It Faster
⌨️Hands-on Keyboard
Learn by Doing
new ThreadPoolExecutor(
10, 50, // core, max
60, TimeUnit.SECONDS,
new ArrayBlockingQueue<>(1000), // BOUNDED
new ThreadPoolExecutor.CallerRunsPolicy()); // backpressure🔥What If?
Think Beyond the Expected
You set maxPoolSize=100 but only ever see 10 threads under heavy load — why?
Because your queue is unbounded (or huge): the pool only grows past corePoolSize when the queue is FULL. With an unbounded queue the queue never fills, so threads never exceed core. Use a bounded queue to actually reach maxPoolSize.
😂Real World
The 'max threads never used' gotcha trips many teams; pairing a bounded queue with CallerRunsPolicy gives natural backpressure (the submitter runs the task) instead of unbounded growth.
🎯Interviewer's Expectation
Keywords they're listening for:
⚠️Common Mistakes
- ✗Expecting maxPoolSize to engage with an unbounded queue
- ✗Using AbortPolicy and not handling rejections
- ✗Oversized pools causing context-switch thrash
✅Best Practices
- ✓Use a bounded queue sized to your latency budget
- ✓Pick a rejection policy intentionally (often CallerRuns)
- ✓Monitor queue depth and active count
🔁Follow-up Questions
- 1What do the four built-in rejection policies do?
- 2How does CallerRunsPolicy create backpressure?
- 3When would you allowCoreThreadTimeOut?
🧩Related Technologies
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: Threads & Pools (Multithreading) Interview question: "How do corePoolSize, maxPoolSize, the queue and rejection policy interact in ThreadPoolExecutor?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
⭐ Featured Products
Support our platform by exploring our recommended products.
As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.