@ Override public final boolean push ( final N n ) { int spin = 0 ; for ( ; ; ) { final long writeLock = seqLock . tryWriteLock ( ) ; if ( writeLock > 0L ) { try { final int stackTop = this . stackTop . get ( ) ; if ( size > stackTop ) { try { stack . set ( stackTop , n ) ; stackNotEmptyCondition . signal ( ) ; return true ; } finally { this . stackTop . set ( stackTop + 1 ) ; } } else { return false ; } } finally { seqLock . unlock ( writeLock ) ; } } spin = Condition . progressiveYield ( spin ) ; } }
add an element to the stack failing if the stack is unable to grow