1、selector.select(timeoutMillis),调用了select方法,并默认设置1秒超时时间,同时记录轮询次数:selectCnt ++;
2、获取当前时间,计算select方法的操作时间是否真的阻塞了timeoutMillis,如果是就证明是一次正常的select(),重置selectCnt = 1;如果不是,就可能触发了JDK的空轮询BUG,然后判断selectCnt 轮询次数是否大于默认的512,然后进行rebuildSelector()。
3、rebuildSelector()方法重新打开一个Selector;然后遍历oldSelector,将所有的key重新注册到新的Selector;然后重新赋值selector,selectCnt = 1;这时候已经规避了空轮询。