@ Override public boolean awaitCompletion ( long timeout , TimeUnit unit ) throws InterruptedException { long deadline = unit . toMillis ( timeout ) + System . currentTimeMillis ( ) ; lock . lock ( ) ; try { assert shutdown ; while ( activeCount != 0 ) { long remaining = deadline - System . currentTimeMillis ( ) ; if ( remaining <= 0 ) { break ; } condition . await ( remaining , TimeUnit . MILLISECONDS ) ; } boolean allComplete = activeCount == 0 ; if ( ! allComplete ) { ProtocolLogger . ROOT_LOGGER . debugf ( "ActiveOperation(s) %s have not completed within %d %s" , activeRequests . keySet ( ) , timeout , unit ) ; } return allComplete ; } finally { lock . unlock ( ) ; } }
Await the completion of all currently active operations .