a-foundation-benchmark/src/main/java/com/ajjpj/afoundation/concurrent/jdk/j9new/ForkJoinPool.java
private boolean tryCompensate(WorkQueue w) {
        boolean canBlock;
        WorkQueue[] ws; long c; int m, pc, sp;
        if (w == null || w.qlock < 0 ||           // caller terminating
            (ws = workQueues) == null || (m = ws.length - 1) <= 0 ||
            (pc = config & SMASK) == 0)           // parallelism disabled
            canBlock = false;
        else if ((sp = (int)(c = ctl)) != 0)      // release idle worker
            canBlock = tryRelease(c, ws[sp & m], 0L);
        else {
            int ac = (int)(c >> AC_SHIFT) + pc;
            int tc = (short)(c >> TC_SHIFT) + pc;
            int nbusy = 0;                        // validate saturation
            for (int i = 0; i <= m; ++i) {        // two passes of odd indices
                WorkQueue v;
                if ((v = ws[((i << 1) | 1) & m]) != null) {
                    if ((v.scanState & SCANNING) != 0)
                        break;
                    ++nbusy;
                }
            }
            if (nbusy != (tc << 1) || ctl != c)
                canBlock = false;                 // unstable or stale
            else if (tc >= pc && ac > 1 && w.isEmpty()) {
                long nc = ((AC_MASK & (c - AC_UNIT)) |
                           (~AC_MASK & c));       // uncompensated
                canBlock = U.compareAndSwapLong(this, CTL, c, nc);
            }
            else if (tc >= MAX_CAP ||
                     (this == common && tc >= pc + commonMaxSpares))
                throw new RejectedExecutionException(
                    "Thread limit exceeded replacing blocked worker");
            else {                                // similar to tryAddWorker
                boolean add = false; int rs;      // CAS within lock
                long nc = ((AC_MASK & c) |
                           (TC_MASK & (c + TC_UNIT)));
                if (((rs = lockRunState()) & STOP) == 0)
                    add = U.compareAndSwapLong(this, CTL, c, nc);
                unlockRunState(rs, rs & ~RSLOCK);
                canBlock = add && createWorker(); // throws on exception
            }
        }
        return canBlock;
    }
private boolean tryCompensate(WorkQueue w) {
        boolean canBlock;
        WorkQueue[] ws; long c; int m, pc, sp;
        if (w == null || w.qlock < 0 ||           // caller terminating
            (ws = workQueues) == null || (m = ws.length - 1) <= 0 ||
            (pc = config & SMASK) == 0)           // parallelism disabled
            canBlock = false;
        else if ((sp = (int)(c = ctl)) != 0)      // release idle worker
            canBlock = tryRelease(c, ws[sp & m], 0L);
        else {
            int ac = (int)(c >> AC_SHIFT) + pc;
            int tc = (short)(c >> TC_SHIFT) + pc;
            int nbusy = 0;                        // validate saturation
            for (int i = 0; i <= m; ++i) {        // two passes of odd indices
                WorkQueue v;
                if ((v = ws[((i << 1) | 1) & m]) != null) {
                    if ((v.scanState & SCANNING) != 0)
                        break;
                    ++nbusy;
                }
            }
            if (nbusy != (tc << 1) || ctl != c)
                canBlock = false;                 // unstable or stale
            else if (tc >= pc && ac > 1 && w.isEmpty()) {
                long nc = ((AC_MASK & (c - AC_UNIT)) |
                           (~AC_MASK & c));       // uncompensated
                canBlock = U.compareAndSwapLong(this, CTL, c, nc);
            }
            else if (tc >= MAX_CAP ||
                     (this == common && tc >= pc + commonMaxSpares))
                throw new RejectedExecutionException(
                    "Thread limit exceeded replacing blocked worker");
            else {                                // similar to tryAddWorker
                boolean add = false; int rs;      // CAS within lock
                long nc = ((AC_MASK & c) |
                           (TC_MASK & (c + TC_UNIT)));
                if (((rs = lockRunState()) & STOP) == 0)
                    add = U.compareAndSwapLong(this, CTL, c, nc);
                unlockRunState(rs, rs & ~RSLOCK);
                canBlock = add && createWorker(); // throws on exception
            }
        }
        return canBlock;
    }
private boolean tryCompensate ( WorkQueue w ) { boolean canBlock ; WorkQueue [ ] ws ; long c ; int m , pc , sp ; if ( w == null || w . qlock < 0 || // caller terminating ( ws = workQueues ) == null || ( m = ws . length - 1 ) <= 0 || ( pc = config & SMASK ) == 0 ) // parallelism disabled canBlock = false ; else if ( ( sp = ( int ) ( c = ctl ) ) != 0 ) // release idle worker canBlock = tryRelease ( c , ws [ sp & m ] , 0L ) ; else { int ac = ( int ) ( c >> AC_SHIFT ) + pc ; int tc = ( short ) ( c >> TC_SHIFT ) + pc ; int nbusy = 0 ; // validate saturation for ( int i = 0 ; i <= m ; ++ i ) { // two passes of odd indices WorkQueue v ; if ( ( v = ws [ ( ( i << 1 ) | 1 ) & m ] ) != null ) { if ( ( v . scanState & SCANNING ) != 0 ) break ; ++ nbusy ; } } if ( nbusy != ( tc << 1 ) || ctl != c ) canBlock = false ; // unstable or stale else if ( tc >= pc && ac > 1 && w . isEmpty ( ) ) { long nc = ( ( AC_MASK & ( c - AC_UNIT ) ) | ( ~ AC_MASK & c ) ) ; // uncompensated canBlock = U . compareAndSwapLong ( this , CTL , c , nc ) ; } else if ( tc >= MAX_CAP || ( this == common && tc >= pc + commonMaxSpares ) ) throw new RejectedExecutionException ( "Thread limit exceeded replacing blocked worker" ) ; else { // similar to tryAddWorker boolean add = false ; int rs ; // CAS within lock long nc = ( ( AC_MASK & c ) | ( TC_MASK & ( c + TC_UNIT ) ) ) ; if ( ( ( rs = lockRunState ( ) ) & STOP ) == 0 ) add = U . compareAndSwapLong ( this , CTL , c , nc ) ; unlockRunState ( rs , rs & ~ RSLOCK ) ; canBlock = add && createWorker ( ) ; // throws on exception } } return canBlock ; }
Tries to decrement active count (sometimes implicitly) and
possibly release or create a compensating worker in preparation
for blocking. Returns false (retryable by caller), on
contention, detected staleness, instability, or termination.

@param w caller
Tries to decrement active count ( sometimes implicitly ) and possibly release or create a compensating worker in preparation for blocking . Returns false ( retryable by caller ) on contention detected staleness instability or termination .