2013年3月17日 星期日

[Android] AsyncTask blocking

In different Android version, there is different handling on AsyncTask, some are in single thread, processed one by one, some are multi-threaded and processed at the same time.

1.0-1.5(API 1-3) single thread.
1.6-2.3.3 (API4-10) multi thread.
3.0+ (API 11 or up) single thread.

but if you want to have AsyncTask run on seperate thread, you can call
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
instead of
    task.execute(params);

then the task will run on seperate thread, and not blocked by other threads.