Compare commits

..
1 Commits
Author SHA1 Message Date
huangyuhui 13a24d5b00 try to fix RejectedExecutionException 2018-02-25 11:10:31 +08:00
2 changed files with 8 additions and 1 deletions

No files matched your search

@@ -36,7 +36,10 @@ class SchedulerExecutorService extends Scheduler {
@Override
public Future<?> schedule(ExceptionalRunnable<?> block) {
return executorService.submit(block.toCallable());
if (executorService.isShutdown() || executorService.isTerminated())
return Schedulers.NONE.schedule(block);
else
return executorService.submit(block.toCallable());
}
}
@@ -17,6 +17,8 @@
*/
package org.jackhuang.hmcl.task;
import org.jackhuang.hmcl.util.Constants;
import java.util.concurrent.*;
/**
@@ -112,6 +114,8 @@ public final class Schedulers {
return newThread();
}
static final Scheduler NONE = new SchedulerImpl(Constants.emptyConsumer());
public static synchronized void shutdown() {
if (CACHED_EXECUTOR != null)
CACHED_EXECUTOR.shutdown();