问题描述
我知道有关于如何并行运行同一AsyncTask的很多问题:我需要的是执行相同的AsyncTask的,但每个任务不同PARAMS
I know there are a lot of question regarding how to run the same asynctask in parallel: what i need is to execute the same asynctask but with different params per task.
我有:
MyTask taskOne = new MyTask();
MyTask taskOne = new MyTask();
taskOne.execute(UrlOne);
taskTwo.execute(UrlTwo);
MyTask不得不从urlone和url两种下载的网页。当两种颜色之一,我杀了另一个与取消(真)。但如何才能在我并行运行的线程?
MyTask have to download the page from the urlone and url two. When one of the two finishes, i kill the other one with cancel(true). But how can i run those thread in parallel?
如果我尝试这一点,当taskOne结束,它只是杀了taskTwo。
If i try this, when taskOne ends it just kill taskTwo.
谢谢大家的帮助。
推荐答案
您应该使用一些同步机制就像一个信号灯或的ConditionObject。
You should have used some synchronization mechanism like a semaphore or a conditionobject.
这篇关于不同PARAMS执行相同的AsyncTask多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!