我正在查看一些 AQuery 代码 here发现AQuery中有修改网络连接数的方法。
有没有办法在改造中做到这一点,改造的默认值是什么?
/* Settings of Image */
//set the max number of concurrent network connections, default is 4
AjaxCallback.setNetworkLimit(8);
//set the max number of icons (image width <= 50) to be cached in memory, default is 20
BitmapAjaxCallback.setIconCacheLimit(50);
//set the max number of images (image width > 50) to be cached in memory, default is 20
BitmapAjaxCallback.setCacheLimit(50);
aq = new AQuery(context);
最佳答案
例如,Retrofit 中的默认连接数在某种程度上是按需的,即为每个新的 Runnable
(连接)提供给 Executor
创建/重用新线程>
您可以通过限制线程
的数量来限制网络连接。当您构建 RestAdapter
时,请执行以下操作:
restAdapterBuilder.setExecutors(Executors.newCachedThreadPool(numberOfConnections), new MainThreadExecutor());
或
restAdapterBuilder.setExecutors(Executors.newFixedThreadPool(numberOfConnections), new MainThreadExecutor());
这与 AQuery 限制连接数的做法完全相同。
参见Executors了解更多
关于retrofit - Retrofit中如何设置最大网络连接数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27617583/