Category: React • Beginner
Published on 22 Feb 2026
Explanation
#white-ExecutorService is a framework in Java #white-used to manage and control thread execution asynchronously.
Code Example
ExecutorService executor = Executors.newFixedThreadPool(2);
executor.submit(() -> System.out.println("Task executed"));
executor.shutdown();
Explanation
#white-ExecutorService helps in reusing threads #white-from a pool #white-instead of creating new threads manually.
Code Example
ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute(() -> System.out.println(Thread.currentThread().getName())); executor.shutdown();
Explanation
#white-submit() method returns a Future object #white-which can be used to get the result of a #white-task.
Code Example
ExecutorService executor = Executors.newSingleThreadExecutor(); Future<Integer> result = executor.submit(() -> 10 + 20); System.out.println(result.get()); executor.shutdown();
Explanation
#white-shutdown() initiates an orderly shutdown #white-where previously submitted tasks are executed.
Code Example
executor.shutdown();
Explanation
#white-shutdownNow() attempts to stop all #white-actively executing tasks immediately.
Code Example
executor.shutdownNow();