How does Java's Future.get()
behave in the case where it is called multiple times after the task is completed? Does it return the the same result? Or does throw an ExecutionException
again and again with the same exception if the computation failed? I can not find anything in the docs about it!
You can call get()
on a Future
as often as you like, and it will only block if the task that produces the result has not finished yet.
If the task has already finished, it will just immediately return the result of the task.
If the task has failed with an exception, calling get()
will throw an ExecutionException
each time you call it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With