修复availableProcessors,潜在的native方法获取CPU个数失败的问题

This commit is contained in:
duandazhi
2022-09-02 22:54:22 +08:00
parent b495a50f28
commit c5c60984cb
4 changed files with 24 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package cn.hutool.socket.aio;
import cn.hutool.core.lang.Console;
import cn.hutool.core.thread.ThreadFactoryBuilder;
import cn.hutool.core.util.RuntimeUtil;
import cn.hutool.core.util.StrUtil;
import java.io.IOException;
@@ -12,7 +13,7 @@ import java.nio.channels.AsynchronousChannelGroup;
public class AioClientTest {
public static void main(String[] args) throws IOException {
final AsynchronousChannelGroup GROUP = AsynchronousChannelGroup.withFixedThreadPool(//
Runtime.getRuntime().availableProcessors(), // 默认线程池大小
RuntimeUtil.getProcessorCount(), // 默认线程池大小
ThreadFactoryBuilder.create().setNamePrefix("Huool-socket-").build()//
);