我在客户时崩溃(使用三星8 android 7.0)。看起来有点像android app crashes when exceeded Thread pool 9 and queued tasks 128,除了在我看来由于设置池大小的方式,我没有任务排队的问题。三星8有8个处理器,对吧?
这里可能出什么问题了?
崩溃输出:
java.lang.RuntimeException:
at android.os.AsyncTask$3.done (AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:354)
at java.util.concurrent.FutureTask.setException (FutureTask.java:223)
at java.util.concurrent.FutureTask.run (FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
at java.lang.Thread.run (Thread.java:762)
Caused by: java.util.concurrent.RejectedExecutionException:
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution (ThreadPoolExecutor.java:2049)
at java.util.concurrent.ThreadPoolExecutor.reject (ThreadPoolExecutor.java:814)
at java.util.concurrent.ThreadPoolExecutor.execute (ThreadPoolExecutor.java:1360)
at java.util.concurrent.AbstractExecutorService.submit (AbstractExecutorService.java:111)
at com.narb.chkapp.Disc.ScanAsync.isOpen (ScanAsync.java:100)
at com.narb.chkapp.Disc.ScanAsync.doInBackground (ScanAsync.java:215)
at com.narb.chkapp.Disc.ScanAsync.doInBackground (ScanAsync.java:36)
at android.os.AsyncTask$2.call (AsyncTask.java:304)
at java.util.concurrent.FutureTask.run (FutureTask.java:237)
Java代码:
@Override
protected Void doInBackground(String... arg0) {
int MAXTHREADS = Runtime.getRuntime().availableProcessors();
MAXTHREADS = 15 * MAXTHREADS;
executor = Executors.newFixedThreadPool(MAXTHREADS);