final void signalWork ( WorkQueue [ ] ws , WorkQueue q ) { long c ; int sp , i ; WorkQueue v ; Thread p ; while ( ( c = ctl ) < 0L ) { // too few active if ( ( sp = ( int ) c ) == 0 ) { // no idle workers if ( ( c & ADD_WORKER ) != 0L ) // too few workers tryAddWorker ( c ) ; break ; } if ( ws == null ) // unstarted/terminated break ; if ( ws . length <= ( i = sp & SMASK ) ) // terminated break ; if ( ( v = ws [ i ] ) == null ) // terminating break ; int vs = ( sp + SS_SEQ ) & ~ INACTIVE ; // next scanState int d = sp - v . scanState ; // screen CAS long nc = ( UC_MASK & ( c + AC_UNIT ) ) | ( SP_MASK & v . stackPred ) ; if ( d == 0 && U . compareAndSwapLong ( this , CTL , c , nc ) ) { v . scanState = vs ; // activate v if ( ( p = v . parker ) != null ) U . unpark ( p ) ; break ; } if ( q != null && q . base == q . top ) // no more work break ; } }
Tries to create or activate a worker if too few are active .