I am using Android HoneyComb.I need to execute some tasks parallely and I am using AsyncTask’s
public final AsyncTask executeOnExecutor (Executor exec, Params… params) method.In each separate thread I am computing some values and I need to store then in an ArrayList.I must then sort all the values in the arrayList and then display it in the UI.Now my question is if one of the thread gets completed earlier than the other then will it immediately call the onPostExecute method or onPostExecute method will be called after all the background threads have been completed?MY program implementation depends on what occurs here.
I am using Android HoneyComb.I need to execute some tasks parallely and I am
Share
Even though using onexecuteExecutor will give you parallel execution, postexecute will be called by each asynctask as soon as it’s finished.
But the asynctask will return itself so that you can know which is which if necessary and track their return order.
The doc
As for managing an arraylist from multiple threads, I think you should take a look at Vectors as they are synchronized with a fail-fast behavior. http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Vector.html