Let's assume, doWork method runs so long and we set timeOut. In this case, does orTimeout kills the running task and the Thread?
CompletableFuture<String> future =
doWork("JavaSampleApproach")
.orTimeout(TIMEOUT, TimeUnit.SECONDS)
.whenComplete((result, error) -> {
if (error == null) {
System.out.println("The result is: " + result);
} else {
System.out.println("Sorry, timeout in " + TIMEOUT + " seconds");
}
});