Skip to content

Instantly share code, notes, and snippets.

@januprasad
Created November 26, 2014 05:23
Show Gist options
  • Save januprasad/37603d8b261d113fd909 to your computer and use it in GitHub Desktop.
Save januprasad/37603d8b261d113fd909 to your computer and use it in GitHub Desktop.
TaskHelper to execute multiple asynctask same time
public class TaskHelper {
public static <P, T extends AsyncTask<P, ?, ?>> void execute(T task) {
execute(task, (P[]) null);
}
public static <P, T extends AsyncTask<P, ?, ?>> void execute(T task, P... params) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
} else {
task.execute(params);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment