question: final void tryTerminate ( ) { for ( ; ; ) { int c = ctl . get ( ) ; if ( isRunning ( c ) || runStateAtLeast ( c , TIDYING ) || ( runStateOf ( c ) == SHUTDOWN && ! workQueue . isEmpty ( ) ) ) return ; if ( workerCountOf ( c ) != 0 ) { interruptIdleWorkers ( ONLY_ONE ) ; return ; } final ReentrantLock mainLock = this . mainLock ; mainLock . lock ( ) ; try { if ( ctl . compareAndSet ( c , ctlOf ( TIDYING , 0 ) ) ) { try { terminated ( ) ; } finally { ctl . set ( ctlOf ( TERMINATED , 0 ) ) ; termination . signalAll ( ) ; } return ; } } finally { mainLock . unlock ( ) ; } } }
target:  Transitions to TERMINATED state if either (SHUTDOWN and pool and queue empty) or (STOP and pool empty).  If otherwise eligible to terminate but workerCount is nonzero, interrupts an idle worker to ensure that shutdown signals propagate. This method must be called following any action that might make termination possible -- reducing worker count or removing tasks from the queue during shutdown. The method is non-private to allow access from ScheduledThreadPoolExecutor.