public static void shutdownChannelFactory( ChannelFactory channelFactory, ExecutorService bossExecutor, ExecutorService workerExecutor, ChannelGroup allChannels) { // Close all channels if (allChannels != null) { closeChannels(allChannels); } // Shutdown the channel factory if (channelFactory != null) { channelFactory.shutdown(); } // Stop boss threads if (bossExecutor != null) { shutdownExecutor(bossExecutor, "bossExecutor"); } // Finally stop I/O workers if (workerExecutor != null) { shutdownExecutor(workerExecutor, "workerExecutor"); } // Release any other resources netty might be holding onto via this channelFactory if (channelFactory != null) { channelFactory.releaseExternalResources(); } }
@Override public void shutdown() { for (ChannelFactory channelFactory : channelFactories) { channelFactory.shutdown(); } }