如何在不执行后期执行链接的情况下同步运行异步任务?
我有三个异步任务,我希望能够同步运行它们.我如何才能做到不将它们放置在彼此的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
谢谢
我希望能够同步运行它们.我怎样才能做到这一点 而不将它们放在彼此的onPostExecute上?
i'd like to be able to run them synchronously. How can I do that without putting them in onPostExecute of eachother?
为三个单独的任务创建自己的线程,并将它们同步以串行执行.请参见此处.这张幻灯片的作者还撰写了有关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, AsyncTask
s 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 ?