public boolean waitForCompletion ( long duration , TimeUnit timeUnit ) throws InterruptedException { synchronized ( lock ) { if ( ! isCompleted ( ) ) { lock . wait ( timeUnit . toMillis ( duration ) ) ; } return isCompleted ( ) ; } }
Blocks until the task is complete or times out .