Skip to content
Advertisement

Tag: java.util.concurrent

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

What does “Aren’t allocating the things put into queues” mean?

I’m reading this: https://concurrency.markmail.org/search/?q=ArrayBlockingQueue+LinkedBlockingQueue#query:ArrayBlockingQueue%20LinkedBlockingQueue%20from%3A%22Doug%20Lea%22+page:1+mid:sgx3amdfga7esqul+state:results In which Doug Lea says: Usually, when you are putting something into a queue, you will have just allocated that new something. And similarly, when you take something out you usually use it and then let it become garbage. In which case the extra allocation for a queue node is not going to make much difference

Why does calling CompletableFuture::cancel cause an immediate CancellationException

I am trying to call cancel on CompletableFuture. It seems from the docs: If not already completed, completes this CompletableFuture with a CancellationException. Dependent CompletableFutures that have not already completed will also complete exceptionally, with a CompletionException caused by this CancellationException. That it should complete them exceptionally which is what I was expecting but instead, it throws and immediate CancellationException.

Advertisement