Skip to content
Advertisement

The speed does not change from an asynchronous request

I need to make about 60 HTTP requests.

In the first case, I did not use an asynchronous request and the speed was about 1.5 minutes. In the second case, I used an asynchronous request and the speed did not change either and was about 1.5 minutes.

Please see my code. Maybe I’m not doing the asynchronous request correctly or is there some other way to quickly make a lot of HTTP requests?

JavaScript
JavaScript
JavaScript

Advertisement

Answer

It doesn’t look like your example is asynchronous at all. Look at the example from https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/AsynchronousGet.java and try with that.

Specifically you should be calling enqueue instead of execute.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement