我在以下方法中从 JobIntentService 调用 asyncTask
public static void search(final String searchTerm, ApiCallback<SearchResult<Item>> apiCallback) {
new SimpleTask<>(new SimpleTask.TaskAction<SearchResult<Item>>() {
@Override
public SearchResult<Item> doTask() {
return new SearchResult<>(
searchTerm,
ArrayUtils.INSTANCE.concat(
SearchController.getSearch(Controller.DRUG, searchTerm)
);
}
}, apiCallback).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
但是得到以下异常
Caused by java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3@fbb2c9 rejected from java.util.concurrent.ThreadPoolExecutor@c1a8dce[Running, pool size = 9, active threads = 9, queued tasks = 128, completed tasks = 22]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2078)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:843)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1389)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:651)