What is the Executor framework in Java?
Why Interviewers Ask This
Mid-level Java roles require deep understanding of this topic. Interviewers ask this to separate candidates who truly understand the mechanics from those who only know surface-level concepts.
Answer
The Executor framework (in java.util.concurrent) provides a high-level replacement for manually creating and managing threads. Instead of new Thread(runnable).start(), you submit tasks to an executor: executor.submit(runnable). The framework decouples task submission from execution policy. ExecutorService manages thread pools. Factory methods in Executors: newFixedThreadPool(n) (n reusable threads), newCachedThreadPool() (grows as needed), newSingleThreadExecutor() (one thread, serial execution), newScheduledThreadPool() (for delayed/periodic tasks). Always shut down executors when done: executor.shutdown().
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.
More Java Questions
View all →- Intermediate What is the Java Collections Framework?
- Intermediate What is the difference between ArrayList and LinkedList?
- Intermediate What is HashMap in Java and how does it work internally?
- Intermediate What is the difference between HashMap and HashTable in Java?
- Intermediate What is the difference between HashMap and LinkedHashMap?