private void processWorkerExit(Worker w,boolean completedAbruptly){
  if (completedAbruptly)   decrementWorkerCount();
  final ReentrantLock mainLock=this.mainLock;
  mainLock.lock();
  try {
    completedTaskCount+=w.completedTasks;
    workers.remove(w);
  }
  finally {
    mainLock.unlock();
  }
  tryTerminate();
  int c=ctl.get();
  if (runStateLessThan(c,STOP)) {
    if (!completedAbruptly) {
      int min=allowCoreThreadTimeOut ? 0 : corePoolSize;
      if (min == 0 && !workQueue.isEmpty())       min=1;
      if (workerCountOf(c) >= min)       return;
    }
    addWorker(null,false);
  }
}

private void processWorkerExit ( Worker w , boolean completedAbruptly ) { if ( completedAbruptly ) decrementWorkerCount ( ) ; final ReentrantLock mainLock = this . mainLock ; mainLock . lock ( ) ; try { completedTaskCount += w . completedTasks ; workers . remove ( w ) ; } finally { mainLock . unlock ( ) ; } tryTerminate ( ) ; int c = ctl . get ( ) ; if ( runStateLessThan ( c , STOP ) ) { if ( ! completedAbruptly ) { int min = allowCoreThreadTimeOut ? 0 : corePoolSize ; if ( min == 0 && ! workQueue . isEmpty ( ) ) min = 1 ; if ( workerCountOf ( c ) >= min ) return ; } addWorker ( null , false ) ; } }
performs cleanup and bookkeeping for a dying worker . called only from worker threads . unless completedabruptly is set , assumes that workercount has already been adjusted to account for exit . this method removes thread from worker set , and possibly terminates the pool or replaces the worker if either it exited due to user task exception or if fewer than corepoolsize workers are running or queue is non - empty but there are no workers .
