private void interruptIdleWorkers(boolean onlyOne){
  final ReentrantLock mainLock=this.mainLock;
  mainLock.lock();
  try {
    Iterator<Worker> it=workers.iterator();
    while (it.hasNext()) {
      Worker w=it.next();
      Thread t=w.thread;
      if (!t.isInterrupted() && w.tryLock()) {
        try {
          t.interrupt();
        }
 catch (        SecurityException ignore) {
        }
 finally {
          w.unlock();
        }
      }
      if (onlyOne)       break;
    }
  }
  finally {
    mainLock.unlock();
  }
}

private void interruptIdleWorkers ( boolean onlyOne ) { final ReentrantLock mainLock = this . mainLock ; mainLock . lock ( ) ; try { Iterator < Worker > it = workers . iterator ( ) ; while ( it . hasNext ( ) ) { Worker w = it . next ( ) ; Thread t = w . thread ; if ( ! t . isInterrupted ( ) && w . tryLock ( ) ) { try { t . interrupt ( ) ; } catch ( SecurityException ignore ) { } finally { w . unlock ( ) ; } } if ( onlyOne ) break ; } } finally { mainLock . unlock ( ) ; } }
interrupts threads that might be waiting for tasks ( as indicated by not being locked ) so they can check for termination or configuration changes . ignores securityexceptions ( in which case some threads may remain uninterrupted ) .
