☕ Java
Intermediate
What is the Executor framework in Java?
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().
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?