瀏覽代碼

feat:修改线程池中线程数

release_toaliyun_real
xmzhao71 2 年之前
父節點
當前提交
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);
}

/**


Loading…
取消
儲存