private int timedAwaitWork(WorkQueue w,long c){
  int stat=0;
  int scale=1 - (short)(c >>> TC_SHIFT);
  long deadline=(((scale <= 0) ? 1 : scale) * IDLE_TIMEOUT_MS + System.currentTimeMillis());
  if ((runState >= 0 || (stat=tryTerminate(false,false)) > 0) && w != null && w.scanState < 0) {
    int ss;
    AuxState aux;
    w.parker=Thread.currentThread();
    if (w.scanState < 0)     LockSupport.parkUntil(this,deadline);
    w.parker=null;
    if ((runState & STOP) != 0)     stat=w.qlock=-1;
 else     if ((ss=w.scanState) < 0 && !Thread.interrupted() && (int)c == ss && (aux=auxState) != null && ctl == c && deadline - System.currentTimeMillis() <= TIMEOUT_SLOP_MS) {
      aux.lock();
      try {
        WorkQueue[] ws;
        int cfg=w.config, idx=cfg & SMASK;
        long nc=((UC_MASK & (c - TC_UNIT)) | (SP_MASK & w.stackPred));
        if ((runState & STOP) == 0 && (ws=workQueues) != null && idx < ws.length && idx >= 0 && ws[idx] == w && U.compareAndSwapLong(this,CTL,c,nc)) {
          ws[idx]=null;
          w.config=cfg | UNREGISTERED;
          stat=w.qlock=-1;
        }
      }
  finally {
        aux.unlock();
      }
    }
  }
  return stat;
}

private int timedAwaitWork ( WorkQueue w , long c ) { int stat = 0 ; int scale = 1 - ( short ) ( c > > > TC_SHIFT ) ; long deadline = ( ( ( scale <= 0 ) ? 1 : scale ) * IDLE_TIMEOUT_MS + System . currentTimeMillis ( ) ) ; if ( ( runState >= 0 || ( stat = tryTerminate ( false , false ) ) > 0 ) && w != null && w . scanState < 0 ) { int ss ; AuxState aux ; w . parker = Thread . currentThread ( ) ; if ( w . scanState < 0 ) LockSupport . parkUntil ( this , deadline ) ; w . parker = null ; if ( ( runState & STOP ) != 0 ) stat = w . qlock = - 1 ; else if ( ( ss = w . scanState ) < 0 && ! Thread . interrupted ( ) && ( int ) c == ss && ( aux = auxState ) != null && ctl == c && deadline - System . currentTimeMillis ( ) <= TIMEOUT_SLOP_MS ) { aux . lock ( ) ; try { WorkQueue [ ] ws ; int cfg = w . config , idx = cfg & SMASK ; long nc = ( ( UC_MASK & ( c - TC_UNIT ) ) | ( SP_MASK & w . stackPred ) ) ; if ( ( runState & STOP ) == 0 && ( ws = workQueues ) != null && idx < ws . length && idx >= 0 && ws [ idx ] == w && U . compareAndSwapLong ( this , CTL , c , nc ) ) { ws [ idx ] = null ; w . config = cfg | UNREGISTERED ; stat = w . qlock = - 1 ; } } finally { aux . unlock ( ) ; } } } return stat ; }
possibly triggers shutdown and tries ( once ) to block worker when pool is ( or may be ) quiescent . waits up to a duration determined by number of workers . on timeout , if ctl has not changed , terminates the worker , which will in turn wake up another worker to possibly repeat this process .
