public E take ( ) throws InterruptedException { final ReentrantLock lock = this . lock ; lock . lockInterruptibly ( ) ; try { while ( a [ start ] == null ) nextObjectReady . await ( ) ; @ SuppressWarnings ( "unchecked" ) final E x = ( E ) a [ start ] ; a [ start ] = null ; start = start + 1 & mask ; -- count ; timeStamp ++ ; newSpaceAvailable . signalAll ( ) ; return x ; } finally { lock . unlock ( ) ; } }
Returns the element with the next timestamp waiting until it is available .