Reputation: 1000
android Asynctask
has been modified quite frequently between different API-levels. I'm developing an Application in which i've to upload images to FTP server. i want to do that in serialized order (images upload after one-another by one image upload per asyntask). I understand the SERIAL_EXECUTOR
and THREAD_POOL_EXECUTOR
stuff, but i just want some clarity about what is the default behavior of asynctask ( my min. target API is ICS 4.0 ). if i simply execute say 10 asyncs' in a loop, will they go to thread queue and execute one by one or they'll just go parallel ?
Upvotes: 0
Views: 56
Reputation: 1648
You can't use one async task with loop inside doInBackground()
? If you want to have control over them, you can invoke second async task in onPostExecute()
of first.
Upvotes: 0
Reputation: 15775
Look in the AsyncTask
documentation:
When first introduced,
AsyncTask
s were executed serially on a single background thread. Starting withDONUT
, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting withHONEYCOMB
, tasks are executed on a single thread to avoid common application errors caused by parallel execution.If you truly want parallel execution, you can invoke
executeOnExecutor(java.util.concurrent.Executor, Object[])
withTHREAD_POOL_EXECUTOR
.
So, with min target of 14, they will be serialized.
Upvotes: 3