From 2e66b1a5460fa6418e688cd39472066c4e02bf30 Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Mon, 29 Jun 2020 20:12:37 +0800 Subject: [PATCH] --- src/org/redkale/net/nio/NioThreadGroup.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/org/redkale/net/nio/NioThreadGroup.java b/src/org/redkale/net/nio/NioThreadGroup.java index 2715b1490..9c1985cd9 100644 --- a/src/org/redkale/net/nio/NioThreadGroup.java +++ b/src/org/redkale/net/nio/NioThreadGroup.java @@ -35,6 +35,12 @@ public class NioThreadGroup { for (int i = 0; i < ioThreads.length; i++) { this.ioThreads[i] = new NioThread(Selector.open(), executor, bufferPool); } + this.timeoutExecutor = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(1, (Runnable r) -> { + Thread t = new Thread(r); + t.setName(this.getClass().getSimpleName() + "-Timeout-Thread"); + t.setDaemon(true); + return t; + }); } public void start() { @@ -47,6 +53,7 @@ public class NioThreadGroup { for (int i = 0; i < ioThreads.length; i++) { this.ioThreads[i].close(); } + this.timeoutExecutor.shutdownNow(); } public NioThread nextThread() {