defaultExecutor()
is an instance method of the CompletableFuture
class. This method is used to get the default pool of threads that are used by the async methods of the CompletableFuture
class when a custom executor is not specified.
The defaultExecutor
method is defined in the CompletableFuture
class. The CompletableFuture
class is defined in the java.util.concurrent
package. To import the CompletableFuture
class, we check the following import statement:
import java.util.concurrent.CompletableFuture;
public Executor defaultExecutor()
This method has no parameters.
This method returns an instance of Executor
.
import java.util.concurrent.*; public class Main { public static void main(String[] args){ CompletableFuture<String> completableFuture = CompletableFuture.completedFuture("hello-educative"); System.out.println(completableFuture.defaultExecutor()); } }
CompletableFuture
, using the completedFuture static method of the CompletableFuture
class.ForkJoinPool
is the default executor for the async methods.Note: The
ForkJoinPool
is a specialized implementation ofExecutorService
implementing the work-stealing algorithm.
RELATED TAGS
CONTRIBUTOR
View all Courses