fix: executor service

This commit is contained in:
huanghongxun
2020-12-19 20:19:46 +08:00
parent 5e8734aa95
commit a828896989
2 changed files with 5 additions and 3 deletions

View File

@@ -51,7 +51,7 @@ public abstract class FetchTask<T> extends Task<T> {
this.urls = new ArrayList<>(urls);
this.retry = retry;
setExecutor(Schedulers.io());
setExecutor(download());
}
public void setCaching(boolean caching) {
@@ -278,7 +278,8 @@ public abstract class FetchTask<T> extends Task<T> {
if (DOWNLOAD_EXECUTOR == null) {
synchronized (Schedulers.class) {
if (DOWNLOAD_EXECUTOR == null) {
DOWNLOAD_EXECUTOR = new ThreadPoolExecutor(0, downloadExecutorConcurrency, 10, TimeUnit.SECONDS, new SynchronousQueue<>(),
DOWNLOAD_EXECUTOR = new ThreadPoolExecutor(0, downloadExecutorConcurrency, 10, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(),
runnable -> {
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setDaemon(true);

View File

@@ -47,7 +47,8 @@ public final class Schedulers {
if (IO_EXECUTOR == null) {
synchronized (Schedulers.class) {
if (IO_EXECUTOR == null) {
IO_EXECUTOR = new ThreadPoolExecutor(0, 4, 10, TimeUnit.SECONDS, new SynchronousQueue<>(),
IO_EXECUTOR = new ThreadPoolExecutor(0, 4, 10, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(),
runnable -> {
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setDaemon(true);