mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-12 21:36:21 -04:00
try to fix RejectedExecutionException
This commit is contained in:
parent
40360cf18a
commit
13a24d5b00
@ -36,7 +36,10 @@ class SchedulerExecutorService extends Scheduler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Future<?> schedule(ExceptionalRunnable<?> block) {
|
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;
|
package org.jackhuang.hmcl.task;
|
||||||
|
|
||||||
|
import org.jackhuang.hmcl.util.Constants;
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,6 +114,8 @@ public final class Schedulers {
|
|||||||
return newThread();
|
return newThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final Scheduler NONE = new SchedulerImpl(Constants.emptyConsumer());
|
||||||
|
|
||||||
public static synchronized void shutdown() {
|
public static synchronized void shutdown() {
|
||||||
if (CACHED_EXECUTOR != null)
|
if (CACHED_EXECUTOR != null)
|
||||||
CACHED_EXECUTOR.shutdown();
|
CACHED_EXECUTOR.shutdown();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user