Answer the question
In order to leave comments, you need to log in
How to send N get requests in parallel and wait for all responses?
You need to make a bunch of requests to a third-party service, and consistently it takes a long time.
Is there anything else besides separate threads? Ideally it would be like js - asynchronously.
Answer the question
In order to leave comments, you need to log in
This seems to be true:
urls.parallelStream().forEach(u ->
{
LOG.debug("Page: " + u + usersResponse.pages.total_pages);
try
{
String r = <Send getRequest>
}
catch (Exception e)
{
LOG.error(e);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question