问题
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.
I have:
MyTask taskOne = new MyTask();
MyTask taskOne = new MyTask();
taskOne.execute(UrlOne);
taskTwo.execute(UrlTwo);
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?
If i try this, when taskOne ends it just kill taskTwo.
Thanks all for help
回答1:
You should have used some synchronization mechanism like a semaphore or a conditionobject.
https://www.youtube.com/playlist?list=PLZ9NgFYEMxp4tbiFYip6tDNIEBRUDyPQK
来源:https://stackoverflow.com/questions/22656332/executing-same-asynctask-multiple-times-with-different-params