Bonjour,
Est il possible d'exécuter deux Asyntask différents en parallèle (en même temps) ?
Merci.
Bonjour,
Est il possible d'exécuter deux Asyntask différents en parallèle (en même temps) ?
Merci.
Un AsyncTask par définition est un tâche Asynchrone . Donc oui.
Oui oui... il y avait dans le code de AsyncTask une limite à 5 workers fut un temps... Je ne sais pas si c'est toujours vrai... mais grosso modo, cela veut dire que 5 tâches tourneront en parallèle, les autres attendront qu'un worker se libère...
Donc si je fais ceci , cela marchera ou il y a une autre façon de les implémenter ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 new Task1().execute(); new Task2().execute();
oui oui ca marchera....
Marchera aussi... sachant que Task6 démarrera quand une autre des taches sera finie.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 new Task1().execute(); new Task2().execute(); new Task3().execute(); new Task4().execute(); new Task5().execute(); new Task6().execute();
Rectification comme l'a dit nicroman ils ont eu un problème :Un AsyncTask par définition est un tâche Asynchrone . Donc oui .
http://stackoverflow.com/questions/4...e-not-possible
Donc pour résumer
la 1.5 , qu'un possible
la 1.6 à la HoneyComb 5 possibles, la HoneyComb a eu également un problème suite à un changement de la procédure
https://groups.google.com/forum/?fro...s/pem0zG2z7j0J
A partir de la HoneyComb on est plus bloqué. on gère nous même la file d'attente.When first introduced, AsyncTasks were executed serially on a single background thread. Starting with DONUT, this was changed to a pool of threads allowing multiple tasks to operate in parallel. After HONEYCOMB, it is planned to change this back to a single thread to avoid common application errors caused by parallel execution. If you truly want parallel execution, you can use the executeOnExecutor(Executor, Params...) version of this method with THREAD_POOL_EXECUTOR; however, see commentary there for warnings on its use.
Partager