本文介绍了从一个活动多asynctasks的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得的数据来自3个不同的休息单个活动调用。我怎样才能做到这一点使用asynctasks。我如何统筹3个任务?

I want to get data from 3 different rest calls in a single activity. How can I do this using asynctasks. How can I co-ordinate 3 tasks?

更新:我想要做的就是等待所有的三个任务,以更新UI之前完成

Update: What I want to do is to wait for all the three tasks to complete before updating UI.

推荐答案

您可以参考这篇文章

AsyncTask的使用线程池从doInBackground运行的东西()。问题是最初(早在Android操作系统版本)中的池大小只是1,这意味着没有并行计算的一堆AsyncTasks的。但是后来它们固定的和现在的大小是5,所以至多5 AsyncTasks可以同时运行。不幸的是我不记得确切在他们改变什么版本。

AsyncTask uses a thread pool pattern for running the stuff from doInBackground(). The issue is initially (in early Android OS versions) the pool size was just 1, meaning no parallel computations for a bunch of AsyncTasks. But later they fixed that and now the size is 5, so at most 5 AsyncTasks can run simultaneously. Unfortunately I don't remember in what version exactly they changed that.

这篇关于从一个活动多asynctasks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 01:44