修改UDP信号协议模块使用线程池方式开启服务

This commit is contained in:
weitang 2025-04-23 14:13:54 +08:00
parent 38859ea331
commit 4c4f61d496

View File

@ -1,6 +1,8 @@
package com.yfd.platform.component.nettyudpserver;
import com.yfd.platform.component.nettyserver.NettyServer;
import com.yfd.platform.utils.ExecutionJob;
import io.netty.channel.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,7 +18,7 @@ public class NettyUdpRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
new Thread(() -> {
ExecutionJob.EXECUTOR.submit(() -> {
NettyUdpServer server = null;
try {
server = new NettyUdpServer(9300);
@ -24,14 +26,14 @@ public class NettyUdpRunner implements CommandLineRunner {
logger.info("NettyUdpRunner running");
channel.closeFuture().sync();
} catch (Exception e) {
logger.error(e.getMessage());;
logger.error(e.getMessage());
;
} finally {
if (server != null) {
server.stop();
}
}
}
).start();
});
}