private boolean tryDropSpare(WorkQueue w){
  if (w != null && w.isEmpty()) {
    long c;
    int sp, wl;
    WorkQueue[] ws;
    WorkQueue v;
    while ((short)((c=ctl) >> TC_SHIFT) > 0 && ((sp=(int)c) != 0 || (int)(c >> AC_SHIFT) > 0) && (ws=workQueues) != null && (wl=ws.length) > 0) {
      boolean dropped, canDrop;
      if (sp == 0) {
        long nc=((AC_MASK & (c - AC_UNIT)) | (TC_MASK & (c - TC_UNIT)) | (SP_MASK & c));
        dropped=U.compareAndSwapLong(this,CTL,c,nc);
      }
 else       if ((v=ws[(wl - 1) & sp]) == null || v.scanState != sp)       dropped=false;
 else {
        long nc=v.stackPred & SP_MASK;
        if (w == v || w.scanState >= 0) {
          canDrop=true;
          nc|=((AC_MASK & c) | (TC_MASK & (c - TC_UNIT)));
        }
 else {
          canDrop=false;
          nc|=((AC_MASK & (c + AC_UNIT)) | (TC_MASK & c));
        }
        if (U.compareAndSwapLong(this,CTL,c,nc)) {
          v.scanState=sp & ~UNSIGNALLED;
          LockSupport.unpark(v.parker);
          dropped=canDrop;
        }
 else         dropped=false;
      }
      if (dropped) {
        int cfg=w.config, idx=cfg & SMASK;
        if (idx >= 0 && idx < ws.length && ws[idx] == w)         ws[idx]=null;
        w.config=cfg | UNREGISTERED;
        w.qlock=-1;
        return true;
      }
    }
  }
  return false;
}

private boolean tryDropSpare ( WorkQueue w ) { if ( w != null && w . isEmpty ( ) ) { long c ; int sp , wl ; WorkQueue [ ] ws ; WorkQueue v ; while ( ( short ) ( ( c = ctl ) > > TC_SHIFT ) > 0 && ( ( sp = ( int ) c ) != 0 || ( int ) ( c > > AC_SHIFT ) > 0 ) && ( ws = workQueues ) != null && ( wl = ws . length ) > 0 ) { boolean dropped , canDrop ; if ( sp == 0 ) { long nc = ( ( AC_MASK & ( c - AC_UNIT ) ) | ( TC_MASK & ( c - TC_UNIT ) ) | ( SP_MASK & c ) ) ; dropped = U . compareAndSwapLong ( this , CTL , c , nc ) ; } else if ( ( v = ws [ ( wl - 1 ) & sp ] ) == null || v . scanState != sp ) dropped = false ; else { long nc = v . stackPred & SP_MASK ; if ( w == v || w . scanState >= 0 ) { canDrop = true ; nc |= ( ( AC_MASK & c ) | ( TC_MASK & ( c - TC_UNIT ) ) ) ; } else { canDrop = false ; nc |= ( ( AC_MASK & ( c + AC_UNIT ) ) | ( TC_MASK & c ) ) ; } if ( U . compareAndSwapLong ( this , CTL , c , nc ) ) { v . scanState = sp & ~ UNSIGNALLED ; LockSupport . unpark ( v . parker ) ; dropped = canDrop ; } else dropped = false ; } if ( dropped ) { int cfg = w . config , idx = cfg & SMASK ; if ( idx >= 0 && idx < ws . length && ws [ idx ] == w ) ws [ idx ] = null ; w . config = cfg | UNREGISTERED ; w . qlock = - 1 ; return true ; } } } return false ; }
if the given worker is a spare with no queued tasks , and there are enough existing workers , drops it from ctl counts and sets its state to terminated .
