android - AsyncTask execute() or executeOnExecutor()? -
what's difference between using execute()
, executeonexecuter()
?
how
execute()
execute tasks default? (in serial or in parallel?)what should used new sdks >16?
is practice use parallel execution (
thread_pool_executor
) tasks rather serial if doesn't matter application or depends on number ofasynctask
s executed?
how .execute execute tasks default (in serial or in parallel).
before api level 11: parallel.
api level 11 , up: serial.
which should used new sdks >16 (executeonexecuter ?)
depends on requirements. use execute()
if you're happy default executor. use explicit executor if you're not.
is practice use parallel execution (thread_pool_executor) tasks rather serial if doesn't matter application or depends on number of async tasks executed?
async tasks should used relative short backround operations. quoting asynctask
documentation:
asynctasks should ideally used short operations (a few seconds @ most.) if need keep threads running long periods of time, highly recommended use various apis provided java.util.concurrent package such executor, threadpoolexecutor , futuretask.
while async task running, executor thread cannot execute other tasks. on serial executor 1 executor thread easier detect problems when tasks run long. on parallel executor detecting such problems takes more simultaneous long-running tasks.
therefore, if need switch parallel executor, you're better off revisiting design.
Comments
Post a Comment