public int select ( long timeout ) throws IOException { fine ( "select(" + timeout + ")" ) ; lock . lock ( ) ; try { ensureAllRunning ( ) ; try { SelKey sk = queue . poll ( timeout , TimeUnit . MILLISECONDS ) ; if ( sk != null ) { selectedKeys . add ( sk ) ; queue . drainTo ( selectedKeys ) ; selectedKeys . remove ( WAKEUP_KEY ) ; return selectedKeys . size ( ) ; } else { fine ( "select() timeout" ) ; return 0 ; } } catch ( InterruptedException ex ) { fine ( "select() interrupted" ) ; return 0 ; } } finally { lock . unlock ( ) ; } }
Selects and waits .