More precisely : If I start async computation by calling submit(Callable<T> task)
method on an ExecutorService
(itself constructed with Executors.newCachedThreadPool()
), I can wait for the computation to finish and retrieve the result by calling Future.get()
.
My question is : if the computation is already finished, what happens until I call get()
? Does the thread is blocked until I retrieved the result? Does the result is stored and the thread assigned to another task? Something completely different?
Thanks in advance for you answers
No, Thread is not blocked, it is returned to the pool.
In general it is the get()
calling thread dependant on worker, not the other way around. So if there is a result, return it, if not, wait until it will be available.
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