Просмотр исходного кода

feat:修改线程池中线程数

release_toaliyun_real
xmzhao71 2 лет назад
Родитель
Сommit
3cd88443b0
2 измененных файлов: 4 добавлений и 4 удалений
  1. +1
    -1
      mallinkService/src/main/java/com/iformall/service/thread/CompletableFutureWithExecutor.java
  2. +3
    -3
      mallinkService/src/main/java/com/iformall/service/thread/ThreadPoolService.java

+ 1
- 1
mallinkService/src/main/java/com/iformall/service/thread/CompletableFutureWithExecutor.java Просмотреть файл

@@ -27,7 +27,7 @@ public class CompletableFutureWithExecutor {
future = this;
}

public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) {
public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) {
return CompletableFuture.supplyAsync(supplier, future.threadPoolService.getExecutorService(CORE_SIZE, MAX_SIZE));
}



+ 3
- 3
mallinkService/src/main/java/com/iformall/service/thread/ThreadPoolService.java Просмотреть файл

@@ -14,8 +14,8 @@ import java.util.concurrent.atomic.AtomicInteger;
@Component
public class ThreadPoolService {

private final Integer coreSize = 2;
private final Integer maxSize = 2 * Runtime.getRuntime().availableProcessors();
private static final Integer CORE_SIZE = 2;
private static Integer MAX_SIZE = 2 * Runtime.getRuntime().availableProcessors();
private final String prefix = "fm-thread-pool-";

private final AtomicInteger nextId = new AtomicInteger();
@@ -26,7 +26,7 @@ public class ThreadPoolService {
private volatile ThreadPoolExecutor service;

private ThreadPoolService() {
getExecutorService(Integer.MAX_VALUE, Integer.MAX_VALUE);
getExecutorService(CORE_SIZE, MAX_SIZE);
}

/**


Загрузка…
Отмена
Сохранить