How does completablefuture works?

66 views Asked by At

Need to know the insights of the complete future task without an executor.

Here is my sample code

CompletableFuture.runAsync(() -> {
    dosomething();
});

How is this task assigned to the thread? Do we have any size for the waiting queue and the thread count?

1

There are 1 answers

4
lance-java On

Have you tried the CompletableFuture javadoc?

public static CompletableFuture runAsync(Runnable runnable)

Returns a new CompletableFuture that is asynchronously completed by a task running in the ForkJoinPool.commonPool() after it runs the given action.

public static CompletableFuture runAsync(Runnable runnable, Executor executor)

Returns a new CompletableFuture that is asynchronously completed by a task running in the given executor after it runs the given action.

See also ForkJoinPool javadoc