question: public synchronized Reference < ? extends T > remove ( long timeoutMillis ) throws InterruptedException { if ( timeoutMillis < 0 ) { throw new IllegalArgumentException ( "timeout < 0: " + timeoutMillis ) ; } if ( head != null ) { return poll ( ) ; } if ( timeoutMillis == 0 || ( timeoutMillis > Long . MAX_VALUE / NANOS_PER_MILLI ) ) { do { wait ( 0 ) ; } while ( head == null ) ; return poll ( ) ; } long nanosToWait = timeoutMillis * NANOS_PER_MILLI ; int timeoutNanos = 0 ; long startTime = System . nanoTime ( ) ; while ( true ) { wait ( timeoutMillis , timeoutNanos ) ; if ( head != null ) { break ; } long nanosElapsed = System . nanoTime ( ) - startTime ; long nanosRemaining = nanosToWait - nanosElapsed ; if ( nanosRemaining <= 0 ) { break ; } timeoutMillis = nanosRemaining / NANOS_PER_MILLI ; timeoutNanos = ( int ) ( nanosRemaining - timeoutMillis * NANOS_PER_MILLI ) ; } return poll ( ) ; }
target:  Returns the next available reference from the queue, removing it in the process. Waits for a reference to become available or the given timeout period to elapse, whichever happens first.