上饶市公安局wvp平台
zhongrj
2023-03-04 9f0367b2515cec04ef6111452e3115bfe6acd405
udp server 启动修改(使用线程池)
1 files modified
15 ■■■■■ changed files
src/main/java/com/genersoft/iot/vmp/netty/server/UdpServer.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/server/UdpServer.java
@@ -11,10 +11,12 @@
import io.netty.util.concurrent.EventExecutorGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
 * updServer udp服务端
 *
 * @author zhongrj
 * @date 2023-02-21
 */
@@ -27,10 +29,11 @@
    //给管道抽象出接口,给Channel更多的能力和配置,例如Channel的状态,参数,IO操作
    //使用ChannelPipeline实现自定义IO
    //Channel channel;
    @Async("taskExecutor")
    public void run(int port) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
//        Thread thread = new Thread(new Runnable() {
//            @Override
//            public void run() {
                //启动服务
                EventLoopGroup workerGroup = new NioEventLoopGroup();
                //优化使用的线程
@@ -79,9 +82,9 @@
                    group.shutdownGracefully();
                    workerGroup.shutdownGracefully();
                }
            }
            });
        thread.start();
//            }
//            });
//        thread.start();
    }
}