private HTTPExchange nextExchange ( int idx ) { assertUnlocked ( ) ; final Thread thread = Thread . currentThread ( ) ; HTTPExchange exch = null ; lock . lock ( ) ; try { do { if ( procThreads == null || ! thread . equals ( procThreads [ idx ] . procThread ) ) { break ; } exch = claimExchange ( idx ) ; if ( exch == null ) { try { notEmpty . await ( ) ; } catch ( InterruptedException intx ) { LOG . log ( Level . FINEST , INTERRUPTED , intx ) ; } } } while ( exch == null ) ; } finally { lock . unlock ( ) ; } return exch ; }
Get the next message exchange to process blocking until one becomes available if nothing is already waiting for processing .