package com.manning.nettyinaction.chapter9; import io.netty.bootstrap.Bootstrap; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.util.concurrent.Future; /** * @author <a href="mailto:norman.maurer@googlemail.com">Norman Maurer</a> */ public class BootstrapShutdownGracefully { public void shutdownGracefully() { EventLoopGroup group = new NioEventLoopGroup(); Bootstrap bootstrap = new Bootstrap(); bootstrap.group(group) .channel(NioSocketChannel.class); // ... // ... Future<?> future = group.shutdownGracefully(); // block until the group has shutdown future.syncUninterruptibly(); } }