I am using Callable, Executor and Future objects to invoke webservices in parallel from separate threads. After having executed all my webservice calls, I display the results in jsp.
Here I have a doubt: if one of the webservice calls fails, how can I show the results from the successful calls in jsp?
If one thread takes more time to execute in that situation I want to skip that response and show the rest of the results in jsp.
I tried to add a Thread.sleep(1000) in one webserice but the response is also delayed in jsp.
If you are using an executor service, you can terminate it with a timeout after having submitted all you callables:
And if you have stored the futures returned by the executor when submitting the jobs, you can loop over the list and check which task has not been completed: