Last active
January 3, 2016 10:39
-
-
Save benigumocom/8450717 to your computer and use it in GitHub Desktop.
バージョンによるAsyncTaskのスケジューリング問題回避
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1.6 以前は、シングルスレッドで順番に実行される | |
1.6 から 2.3、スレッドプールで並列に実行される。 | |
3.0 以降、デフォルトで以前の動作に戻る。スレッドプール利用はexecuteOnExecutor()で。 | |
今どきの端末ではデフォルトでは並列実行されない。 | |
*/ | |
public class ConcurrentAsyncTask { | |
public static void execute(AsyncTask as) { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { | |
as.execute(); | |
} else { | |
as.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment