Skip to content

Commit 0f416c1

Browse files
author
Peter Svensson
committed
expose the shutdown method of the event loop group
To exit normally all non-daemon threads of the java process are supposed to have stopped. TcpClientSession creates an static class member EventLoopGroup which in turn instantiates worker threads. These need to be stopped as a part of shutting down the server. This patch exposes the shutdown of the EventLoopGroup as a static function intended to be called by some central function as a part of server shutdwon.
1 parent bfb6430 commit 0f416c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,15 @@ private static void createTcpEventLoopGroup() {
318318

319319
Runtime.getRuntime().addShutdownHook(new Thread(() -> EVENT_LOOP_GROUP.shutdownGracefully()));
320320
}
321+
322+
public static void shutdown() {
323+
if (EVENT_LOOP_GROUP != null) {
324+
try {
325+
EVENT_LOOP_GROUP.shutdownGracefully().sync();
326+
} catch (InterruptedException e) {
327+
e.printStackTrace();
328+
}
329+
330+
}
331+
}
321332
}

0 commit comments

Comments
 (0)