android - running multiple AsyncTasks: task.executeOnExecutor not working -
i have college project need use threads run tasks in paralel. started using asynctask , simple task.execute(params), found out not allow multiple asynctasks run, 1 per time. discovered task.executeonexecutor, use this(code inside elevatorcontrol class):
taskdesligalampada.executeonexecutor(asynctask.thread_pool_executor, "");
i execute in elevatorcontrol class(which not activity). funny thing is: executeonexecutor not starting doinbackground method of task. tried using logging debuggig this(inside asynctask):
@override protected string doinbackground(string... string_qualquer) { //parei aki parece que essa task nÃo executa. problema execute on executor? log.i("elevatorcontrol", "elevador id=" + elevatorcontrol.getidelevador() + ";fechando porta"); this.interfacedaporta.fecharporta(andaratual, this.elevatorcontrol.getidelevador()); return ""; }
but log not appear on logcat, means it's not running. tried catching state variable returned after executteonexecutor this(method inside elevatorcontrol task):
//os eventos abaixo deveriam ser concorrentes. por isso tasks foram criadas taskfechaporta taskfechaporta = new taskfechaporta(this, interfacedaporta, sobeoudesceouparado, andaratual); status statusthreadroda = taskfechaporta.executeonexecutor(asynctask.thread_pool_executor, "").getstatus();
and, debugging, found out status "running". why not running doinbackground method of task?
can me doing wrong?
p.s.: use lot of asynctasks project, @ least 18 running because teacher said so.
first of all, android has limit of threads , asynctask. "all asynctasks controlled internally shared (static) threadpoolexecutor , linkedblockingqueue. when call execute on asynctask, threadpoolexecutor execute when ready time in future."
in post:android asynctask threads limits?
what version of android? feature available since honeycomb.
regards.
Comments
Post a Comment