android.os.AsyncTaskからソース コードを借りて、独自の com.company.AsyncTask 実装を作成します。この実装では、独自のコードで必要なすべてを制御できます。
android.os.AsyncTask には、THREAD_POOL_EXECUTOR と SERIAL_EXECUTOR の 2 つのベイク済みエグゼキュータが付属しています。
private static final BlockingQueue<Runnable> sPoolWorkQueue =
new LinkedBlockingQueue<Runnable>(10);
/**
* An {@link Executor} that can be used to execute tasks in parallel.
*/
public static final Executor THREAD_POOL_EXECUTOR
= new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE,
TimeUnit.SECONDS, sPoolWorkQueue, sThreadFactory);
/**
* An {@link Executor} that executes tasks one at a time in serial
* order. This serialization is global to a particular process.
*/
public static final Executor SERIAL_EXECUTOR = new SerialExecutor();
com.company.AsyncTask で、別の PRIORITY_THREAD_POOL_EXECUTOR を作成し、すべての実装をこのクラス (すべての内部フィールドに可視性がある場所) 内にラップし、次のように AysncTask を使用します。
com.company.AsyncTask asyncTask = new com.company.AsyncTask();
asyncTask.setPriority(1);
asyncTask.executeOnExecutor(com.company.AsyncTask.PRIORITY_THREAD_POOL_EXECUTOR, (Void[]) null);
ここで私の回答を確認し、API レベル 11 より前に executeOnExecutor() を機能させるために独自の AsyncTask を作成する方法を確認してください。