本文介绍了如何在不执行后期执行链接的情况下同步运行异步任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个异步任务,我希望能够同步运行它们.我如何才能做到不将它们放置在彼此的onPostExecute中?很抱歉,如果已解决此问题,但我似乎无法在Google或此处找到正确的关键词.

I have three async tasks, and i'd like to be able to run them synchronously. How can I do that without putting them in onPostExecute of eachother? I'm sorry if this has been covered but I can't seem to get the right key words on google or on here.

new parseZip().execute();
new loadContent().execute();
new playContent().execute();

任何帮助将不胜感激,或者仅是指向线程的链接

Any help would be appreciated, or just a link to a thread

谢谢

推荐答案

为三个单独的任务创建自己的线程,并将它们同步以串行执行.请参见此处.这张幻灯片的作者还撰写了有关Android中多线程的书.

Create your own threads for the three separate tasks and synchronize them to execute serially. See here. The author of this slide has also written a book on multithreading in Android.

另请参见 指定要在线程上运行的代码 示例.

See also the Specifying the Code to Run on a Thread example.

顺便说一句,AsyncTask默认情况下是连续运行的.如果我是你,我只是将它们放在彼此的onPostExecute()中.怎么了?

As an aside, AsyncTasks are run serially by default. If I were you, I'd simply put them in the onPostExecute() of each other. What's wrong with that ?

这篇关于如何在不执行后期执行链接的情况下同步运行异步任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 04:26