protected T _getResultWithTimeout ( final long timeout ) throws TimeoutException { if ( timeout <= 0 ) cond . waitFor ( this :: hasResult ) ; else if ( ! cond . waitFor ( this :: hasResult , timeout , TimeUnit . MILLISECONDS ) ) throw new TimeoutException ( ) ; return result ; }
Blocks until a result is available or timeout milliseconds have elapsed . Needs to be called with lock held