### Question:
NioEventLoop extends SingleThreadEventLoop { public void rebuildSelector() { if (!inEventLoop()) { execute(new Runnable() { @Override public void run() { rebuildSelector0(); } }); return; } rebuildSelector0(); } NioEventLoop(NioEventLoopGroup parent, Executor executor, SelectorProvider selectorProvider,
                 SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler); SelectorProvider selectorProvider(); void register(final SelectableChannel ch, final int interestOps, final NioTask<?> task); int getIoRatio(); void setIoRatio(int ioRatio); void rebuildSelector();  }### Answer:
@Test public void testRebuildSelector() { EventLoopGroup group = new NioEventLoopGroup(1); final NioEventLoop loop = (NioEventLoop) group.next(); try { Channel channel = new NioServerSocketChannel(); loop.register(channel).syncUninterruptibly(); Selector selector = loop.unwrappedSelector(); assertSame(selector, ((NioEventLoop) channel.eventLoop()).unwrappedSelector()); assertTrue(selector.isOpen()); loop.submit(new Runnable() { @Override public void run() { loop.rebuildSelector(); } }).syncUninterruptibly(); Selector newSelector = ((NioEventLoop) channel.eventLoop()).unwrappedSelector(); assertTrue(newSelector.isOpen()); assertNotSame(selector, newSelector); assertFalse(selector.isOpen()); channel.close().syncUninterruptibly(); } finally { group.shutdownGracefully(); } }