Volley库是否按顺序处理所有请求 [英] Does Volley library handles all the request sequentially

查看:69
本文介绍了Volley库是否按顺序处理所有请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用volley库执行网络操作以加快处理速度.我的问题是,Volley是否按顺序或并行执行已添加到队列中的请求.

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.

假设我添加了Req1,Req2,Req3之类的请求,它们将开始并行运行还是第二个请求将等到第一个完成?

Suppose I add request like Req1, Req2, Req3 , Will they start to run parallel or second request will wait until first finished ??

推荐答案

根据 Volley文档

Volley维护多个网络线程.如果某个线程没有执行任何操作,那么它将在队列中执行一项工作.

Volley maintains several network threads. If a thread is not doing anything, then it will take on a job in the queue.

要回答您的问题,请将Req1,Req2和Req3分别放置在工作线程中并并行运行.

To answer your question, Req1, Req2 and Req3 will each be placed in a worker thread and will run in parallel.

Volley还会缓存您下载的数据(并根据下载数据的HTTP标头中的到期时间确定是否重新下载),因此,如果不需要再次下载数据,则从缓存中获取数据. ,比重新下载要快.

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.

在某些情况下,Volley被认为比标准网络操作更快,这是其中的一些原因.您当然可以自己实现,但是Google为您做了很多辛苦的工作.

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.

这篇关于Volley库是否按顺序处理所有请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆