I am using volley
library for performing network operation to speed up the things. My Question is that Does Volley executes the requests which have added in the queue sequentially or parallel.
Suppose I add request like Req1, Req2, Req3 , Will they start to run parallel or second request will wait until first finished ??
Usually a queue starts each operation according to the order it was queued, unless it's a priority queue.
Therefore, assuming equal priority (Assuming that the Volley queue is non priority queue), we can conclude that
Req1
will get started first. ThenReq2
, followed byReq3
.However, we can not guarantee the order which each finishes. If
Req1
is time consuming, then the requests will finish in a different order thanReq1
,Req2
,Req3
.All we can guarantee is that they will be started in the order
Req1
,Req2
,Req3
.According to the Volley documentation
Volley maintains several network threads. If a thread is not doing anything, then it will take on a job in the queue.
To answer your question, Req1, Req2 and Req3 will each be placed in a worker thread and will run in parallel.
Volley also caches your downloaded data (and determines whether to re-download based on the expire time in the HTTP header of the downloaded data), so if your data doesn't need to be downloaded again, it's fetched from the cache, which is faster than re-downloading.
These are some of the reasons that Volley is proclaimed to be faster than standard network operations for the situations that it's appropriate to use it. You can, of course, implement this yourself, but Google has done a lot of the hard work for you.