question: private boolean addWorker ( Runnable firstTask , boolean core ) { retry : for ( ; ; ) { int c = ctl . get ( ) ; int rs = runStateOf ( c ) ; if ( rs >= SHUTDOWN && ! ( rs == SHUTDOWN && firstTask == null && ! workQueue . isEmpty ( ) ) ) return false ; for ( ; ; ) { int wc = workerCountOf ( c ) ; if ( wc >= CAPACITY || wc >= ( core ? corePoolSize : maximumPoolSize ) ) return false ; if ( compareAndIncrementWorkerCount ( c ) ) break retry ; c = ctl . get ( ) ; if ( runStateOf ( c ) != rs ) continue retry ; } } boolean workerStarted = false ; boolean workerAdded = false ; Worker w = null ; try { w = new Worker ( firstTask ) ; final Thread t = w . thread ; if ( t != null ) { final ReentrantLock mainLock = this . mainLock ; mainLock . lock ( ) ; try { int rs = runStateOf ( ctl . get ( ) ) ; if ( rs < SHUTDOWN || ( rs == SHUTDOWN && firstTask == null ) ) { if ( t . isAlive ( ) ) throw new IllegalThreadStateException ( ) ; workers . add ( w ) ; int s = workers . size ( ) ; if ( s > largestPoolSize ) largestPoolSize = s ; workerAdded = true ; } } finally { mainLock . unlock ( ) ; } if ( workerAdded ) { t . start ( ) ; workerStarted = true ; } } } finally { if ( ! workerStarted ) addWorkerFailed ( w ) ; } return workerStarted ; }
target:  Checks if a new worker can be added with respect to current pool state and the given bound (either core or maximum). If so, the worker count is adjusted accordingly, and, if possible, a new worker is created and started, running firstTask as its first task. This method returns false if the pool is stopped or eligible to shut down. It also returns false if the thread factory fails to create a thread when asked.  If the thread creation fails, either due to the thread factory returning null, or due to an exception (typically OutOfMemoryError in Thread.start()), we roll back cleanly.