a-foundation/src/main/java/com/ajjpj/afoundation/concurrent/SharedQueueNonblockPushBlockPopImpl.java
@Override public void push (Runnable task) {
        lock ();

        final long _base;
        final long _top;
        try {
            _base = UNSAFE.getLongVolatile (this, OFFS_BASE);
            _top = UNSAFE.getLongVolatile (this, OFFS_TOP);

            if (_top == _base + mask) {
                throw new RejectedExecutionExceptionWithoutStacktrace ("Shared queue overflow");
            }

            // We hold a lock here, so there can be no concurrent modifications of 'top', and there is no need for CAS. We must however ensure that
            //  no concurrently reading thread sees the incremented 'top' without the task being present in the array, therefore the 'ordered' put.
            UNSAFE.putObjectVolatile (tasks, taskOffset (_top), task);
            UNSAFE.putLongVolatile (this, OFFS_TOP, _top+1);
        }
        finally {
            unlock ();
        }

        pool.onAvailableTask ();
    }
@Override public void push (Runnable task) {
        lock ();

        final long _base;
        final long _top;
        try {
            _base = UNSAFE.getLongVolatile (this, OFFS_BASE);
            _top = UNSAFE.getLongVolatile (this, OFFS_TOP);

            if (_top == _base + mask) {
                throw new RejectedExecutionExceptionWithoutStacktrace ("Shared queue overflow");
            }

            // We hold a lock here, so there can be no concurrent modifications of 'top', and there is no need for CAS. We must however ensure that
            //  no concurrently reading thread sees the incremented 'top' without the task being present in the array, therefore the 'ordered' put.
            UNSAFE.putObjectVolatile (tasks, taskOffset (_top), task);
            UNSAFE.putLongVolatile (this, OFFS_TOP, _top+1);
        }
        finally {
            unlock ();
        }

        pool.onAvailableTask ();
    }
@ Override public void push ( Runnable task ) { lock ( ) ; final long _base ; final long _top ; try { _base = UNSAFE . getLongVolatile ( this , OFFS_BASE ) ; _top = UNSAFE . getLongVolatile ( this , OFFS_TOP ) ; if ( _top == _base + mask ) { throw new RejectedExecutionExceptionWithoutStacktrace ( "Shared queue overflow" ) ; } // We hold a lock here, so there can be no concurrent modifications of 'top', and there is no need for CAS. We must however ensure that //  no concurrently reading thread sees the incremented 'top' without the task being present in the array, therefore the 'ordered' put. UNSAFE . putObjectVolatile ( tasks , taskOffset ( _top ) , task ) ; UNSAFE . putLongVolatile ( this , OFFS_TOP , _top + 1 ) ; } finally { unlock ( ) ; } pool . onAvailableTask ( ) ; }
Add a new task to the top of the shared queue, incrementing 'top'.
Add a new task to the top of the shared queue incrementing top .