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
Tag: completable-future
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
Is there a way to calculate the time required to complete every completableFuture?
Before I jump into the specifics of the question, I want to give the context of the problem. Basically, my code looks like Now what i want to do is run doSomething() as a completableFuture and get the responseTime as mentioned above. But since doing something like this would be totally incorrect — since it would defeat the purpose of
Exception propagation in CompletableFuture (java)
How can I propagate exception encountered in the following code inside CompletableFuture.runAsync to my main thread? I want to catch the IllegalStateException in my main thread. CompletableFuture….
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