Q46: How does ExecutorService manage Thread Pools, and what are the standard pool implementations?
ExecutorService decouples task submission from thread management.
FixedThreadPool: Fixed number of reusable threads backed by an unboundedLinkedBlockingQueue.CachedThreadPool: Creates new threads dynamically as needed; reclaims idle threads after 60s. Backed bySynchronousQueue.SingleThreadExecutor: Sequential single-worker execution.ScheduledThreadPool: Executes tasks periodically or after delays.
Key Takeaways
FixedThreadPooluses an unbounded task queue (risk of OOM if overwhelmed).CachedThreadPoolcreates threads dynamically (risk of high thread counts).
Knowledge Check
What memory risk is associated with default Executors.newFixedThreadPool(10) under heavy load?