Skip to content

Tag: completable-future

Java concurrent programming – endless loop

I am reading the book Introducing Play Framework: Java Web Application Development (ISBN 978-1-4842-5645-9) and there is this example on Callable: My question is, if the computation of the Future throws and exception, will the while loop run forever? In my opinion, yes, it will loop forever. First, if the Future computation throws an exception, then future.isDone() always evaluates to

Asynchronous execution/operation with CompletableFuture in Java 8+

In Java, is calling get() method while looping on CompletableFuture instances as good as doing synchronous operations although CompletableFuture is used for async calls? Answer ‘get()’ waits until the future is completed. If that’s what you want, it’s what you use. There’s no general rule. For example, you might be using a method that is inherently asynchronous, but in your

Mono vs CompletableFuture

CompletableFuture executes a task on a separate thread ( uses a thread-pool ) and provides a callback function. Let’s say I have an API call in a CompletableFuture. Is that an API call blocking? Would the thread be blocked till it does not get a response from the API? ( I know main thread/tomcat thread will be non-blocking, but what