Skip to main content

All Questions

Filter by
Sorted by
Tagged with
4 votes
1 answer
1k views

CompletableFuture inside another CompletableFuture doesn't join with timeout

I have one completable future that just runs another completable future(that takes always about 2 seconds and timeout of 50 ms) and waits for it to complete with timeout 1 second. The problem is ...
MediaNik Ok's user avatar
0 votes
1 answer
941 views

Java8 - CompletableFuture - Running methods in async call sequentially

So I have this code block: someMethod(SomeParameter someParameter) { for (SomeObject: object) { if (someObject is true) { callSomeMethod(someParameter); } else { ...
Jet Waitforit Torres's user avatar
0 votes
1 answer
380 views

Java Completable future thread are alive after method execute

I have written a small program to check behavior of Completable Future. I have not overridden the common pool. I did not found any shut down method and when i print active number of thread at the end, ...
Rahul Kumar's user avatar
1 vote
0 answers
301 views

Java runAsync and ForkJoin when vCPU is 2

I have a calculation heavy spring boot application that runs on an AWS t3.large EC2 instance, with 2 virtual CPUs. I have two steps in the calculation and for the first step, I intend to use ...
maheeka's user avatar
  • 2,093
9 votes
1 answer
16k views

Java CompletableFuture threadpool used

In the code below no matter what I set as the max value of i, the total number of threads never crosses 13. What thread pool does it use? Where can I find its default settings? public static void main(...
Foo's user avatar
  • 4,606
0 votes
1 answer
70 views

How to make operation with potential DB interactions in parallel on list

I try to make my code work more efficiently so I try to understand how to make it work with Futures and ForkJoinPool. For now I have code that works like this: @RestController @RequestMapping(SEND) @...
Sheyko Dmitriy's user avatar
4 votes
1 answer
449 views

Why does CompletableFuture.runAsync() not always submit to ForkJoinPool.commonPool()?

CompletableFuture.runAsync documentation states: Returns a new CompletableFuture that is asynchronously completed by a task running in the ForkJoinPool.commonPool() after it runs the given action. ...
Christian S.'s user avatar
4 votes
2 answers
2k views

Using CompletableFuture.runAsync() vs ForkJoinPool.execute()

Without passing an Executor to CompletableFuture.runAsync(), the common ForkJoinPool is used. Instead, for a simple task (e.g., I do not need to chain different tasks) that I want to be executed ...
Christian S.'s user avatar
3 votes
1 answer
856 views

Why does ForkJoinPool use ThreadPerTaskExecutor?

We run an Akka application in Java on two CPU environment and we observed that with every tell a new Thread is initiated instead of taking them from the pool. Akka default dispatcher uses ForkJoinPool ...
arc's user avatar
  • 31
5 votes
1 answer
6k views

Exception propagation in java.util.concurrent.CompletableFuture

There are two snippets of code. In the first one we create the CompletableFuture from the task which always throws some exception. Then we apply "exceptionally" method to this future, then "theAccept"...
Andrey Sukhovitsky's user avatar
2 votes
2 answers
3k views

Behaviour of ForkJoinPool in CompletableFuture.supplyAsync()

I'm comparing the behaviour of CompletableFuture.supplyAsync() in the two cases in which I set a custom ExecutorService or I want my Supplier to be executed by the default executor (if not specified) ...
Alessandro Argentieri's user avatar
1 vote
1 answer
828 views

core-count tasks CompletableFuture slower than parallelStream

My PC is four-cored (FYI) CompletableFuture will use ForkJoinPool.commonPool() as its official doc points out: All async methods without an explicit Executor argument are performed using the ...
Hearen's user avatar
  • 7,848
54 votes
5 answers
19k views

In which thread do CompletableFuture's completion handlers execute?

I have a question about CompletableFuture method: public <U> CompletableFuture<U> thenApply(Function<? super T, ? extends U> fn) The thing is the JavaDoc says just this: Returns a ...
St.Antario's user avatar
  • 27.5k
13 votes
2 answers
31k views

Default ForkJoinPool executor taking long time

I am working with the CompletableFuture for async execution of a stream generated from a list source. so i am testing the overloaded method i.e. "supplyAsync" of CompletableFuture in which ...
KayV's user avatar
  • 13.9k
4 votes
0 answers
488 views

Caveat of using ManagedBlocker inside CompletableFuture?

I want to use ManagedBlocker with CompletableFuture to prevent ForkJoinPool.commonPool from exhaustion, i.e.: @Test public void testCompletableFutureWithManagedBlocker() throws ExecutionException, ...
Yudhistira Arya's user avatar

15 30 50 per page