我有三个异步任务,我希望能够同步运行它们。如果不将它们放在彼此的 onPostExecute
中,我该怎么做?很抱歉,如果这已被涵盖,但我似乎无法在谷歌或此处获得正确的关键词。
new parseZip().execute();
new loadContent().execute();
new playContent().execute();
任何帮助将不胜感激,或者只是一个线程的链接
谢谢
最佳答案
i'd like to be able to run them synchronously. How can I do that without putting them in onPostExecute of eachother?
为三个独立的任务创建自己的线程,并同步它们以串行执行。参见 here .这张幻灯片的作者还写了一本关于 Android 多线程的书。
另见 Specifying the Code to Run on a Thread示例。
顺便说一句,AsyncTask
默认连续运行。如果我是你,我会简单地将它们放在彼此的 onPostExecute()
中。这有什么问题吗?
关于java - 如何在没有执行后链接的情况下同步运行异步任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28876914/