Default Executor: ForkJoinPool.commonPool()
You'll learn: What executor CompletableFuture uses by default when you call async methods and when this automatic executor kicks in.
The Automatic Thread Pool
When you use supplyAsync, thenApplyAsync, thenAcceptAsync, or any other async method on CompletableFuture without explicitly providing an executor, Java doesn't block your main thread or create new threads randomly. Instead, it automatically uses a shared, global thread pool called ForkJoinPool.commonPool().
Think of ForkJoinPool.commonPool() as a ready-to-use delivery service that all CompletableFutures can share. You don't need to set it up or manage it—it's always there, waiting to handle your async tasks. This pool is optimized for CPU-bound work and scales based on your machine's processor count (typically processors - 1 threads).
When Is It Applied?
Every time you call an async method variant without passing a custom executor parameter, you're implicitly using the common pool:
CompletableFuture.supplyAsync(() -> "Hello"); // Uses commonPool
CompletableFuture.runAsync(() -> System.out.println("Task")); // Uses commonPool
future.thenApplyAsync(s -> s.toUpperCase()); // Uses commonPool
future.thenAcceptAsync(System.out::println); // Uses commonPool
If you provide your own executor, the common pool is bypassed entirely.
Why It Matters
Understanding this default behavior helps you reason about thread usage and resource consumption. The common pool is shared across your entire application, so heavy usage can impact other async operations. For specialized needs (like I/O-bound tasks or custom thread configurations), you should provide your own executor.
Key Takeaway: CompletableFuture automatically uses ForkJoinPool.commonPool() as the default executor for all async methods when no custom executor is specified, providing a shared, managed thread pool for asynchronous operations.