1

After following this answer here : answer how to limit retrofit network calls

I am doing this:

RestAdapter restAdapter = new RestAdapter.Builder()
    .setEndpoint(url)
    .setExecutors(Executors.newFixedThreadPool(5),
        new MainThreadExecutor())
    .setClient(new OkClient())
    .build();

To test that this is working, i run a for loop, from 0 to 1000, where in each iteration i fire a request. However, instead of only 5 requests being sent at every given moment, the app fires all 1000 of them at the same time. What am I doing wrong?

Community
  • 1
  • 1
shaya ajzner
  • 179
  • 1
  • 9
  • `the app fires all 1000 of them at the same time` - how did you check it? – nikis May 11 '15 at 13:03
  • thanks for the reply. I'm using charles, a network sniffer, i can see it's firing all of them at the same time – shaya ajzner May 11 '15 at 13:04
  • It is not because retrofit fires all the 1000 requests that means there is 1000 connections. – Dimitri May 11 '15 at 13:20
  • Dimitri, isn't the line Executors.newFixedThreadPool(5) supposed to make sure that there are no more than 5 "connections", that's what I understood is supposed to happen. thank you in advance – shaya ajzner May 11 '15 at 14:15

0 Answers0