div
div

Reputation: 1

How does completablefuture works?

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?

Upvotes: -1

Views: 191

Answers (1)

lance-java
lance-java

Reputation: 28061

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

Upvotes: 1

Related Questions