longbefore=now;intselected=selector.select(wait);
now=System.currentTimeMillis();
_idleTimeout.setNow(now);
_timeout.setNow(now);//Look for JVM bugs//http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6403933if(__JVMBUG_THRESHHOLD>0&&selected==0&&wait>__JVMBUG_THRESHHOLD&&(now-before)
{
_jvmBug++;if(_jvmBug>=(__JVMBUG_THRESHHOLD2))
{synchronized(this)
{
_lastJVMBug=now;//BLOODY SUN BUG !!! Try refreshing the entire selector.finalSelector new_selector=Selector.open();for(SelectionKey k: selector.keys())
{if(!k.isValid()||k.interestOps()==0)continue;finalSelectableChannel channel=k.channel();finalObject attachment=k.attachment();if(attachment==null)
addChange(channel);elseaddChange(channel,attachment);
}
_selector.close();
_selector=new_selector;
_jvmBug=0;return;
}
}elseif(_jvmBug==__JVMBUG_THRESHHOLD||_jvmBug==__JVMBUG_THRESHHOLD1)
{//Cancel keys with 0 interested opsfor(SelectionKey k: selector.keys())
{if(k.isValid()&&k.interestOps()==0)
{
k.cancel();
}
}return;
}
}else_jvmBug=0;