JavaAdvanced#concurrency

What is the Executor framework?

java.util.concurrent.Executor decouples task submission from execution. ExecutorService manages a thread pool, returns Futures. Use Executors.newFixedThreadPool or ThreadPoolExecutor for fine control.

Example
ExecutorService pool = Executors.newFixedThreadPool(4);
Future<Integer> future = pool.submit(() -> 2 + 2);
future.get(); // 4
pool.shutdown();

Related Questions

1
JavaIntermediate#concurrency

What is the difference between Callable and Runnable?

Open
2
JavaAdvanced#concurrency

Explain wait(), notify() and notifyAll().

Open
3
JavaAdvanced#design-patterns

What is the Singleton pattern? How to implement it thread-safely?

Open