Future.get () and InterruptedException Asynchronous Streaming
Im using asynchronous streaming in my application using httpClient. I am making a call using Future Api, so
mStrResults = (String) rssFuture.get();
this call is trying to fetch the html string returned from my Callable httpClient call () method.
However, I want to ensure that the get method doesn't wait too long when the call () method is executed. Should I pass a timeout parameter when calling rssFuture.get (), or is it okay to block the Exception interrupt?
Also there is a default time that the async thread will wait before InterruptedException is thrown, and if so, can I set a custom value?
source to share
You must use Future. get (long timeout, TimeUnit unit) and catch TimeoutException. There is no default timeout for get (), it will always wait.
InterruptedException will not be thrown unless the thread calling Future.get () is interrupted.
source to share