Skip to content

Tag: java.util.concurrent

Resubmit Callable to executorService on exception

My situation I’m trying to craft a functionality which would execute n (where n >=0) requests to a given endpoint, but I do understand that sometimes that endpoint might not respond due to 500 error or other issue, so I want to repeat my requests to an endpoint (with a small interval in between [not …

CompletableFuture from Callable?

Today I experimented with the “new” CompletableFuture from Java 8 and found myself confused when I didn’t find a runAsync(Callable) method. I can do it myself like shown below, but why is this (to me very obvious and useful utility method) missing? Am I missing something? Answer You are supp…

future.cancel does not work

I have a nice and compact code, which does not work as I expected. The output is : Timeout true END Question: Why does not terminate the future.cancel(true) method the called Runnable? After the program wrote the “END” to the output, the “r” Runnable is still running. Answer The proble…