private void checkShutdownAccess(){
  SecurityManager security=System.getSecurityManager();
  if (security != null) {
    security.checkPermission(shutdownPerm);
    final ReentrantLock mainLock=this.mainLock;
    mainLock.lock();
    try {
      for (      Worker w : workers)       security.checkAccess(w.thread);
    }
  finally {
      mainLock.unlock();
    }
  }
}

private void checkShutdownAccess ( ) { SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { security . checkPermission ( shutdownPerm ) ; final ReentrantLock mainLock = this . mainLock ; mainLock . lock ( ) ; try { for ( Worker w : workers ) security . checkAccess ( w . thread ) ; } finally { mainLock . unlock ( ) ; } } }
if there is a security manager , makes sure caller has permission to shut down threads in general ( see shutdownperm ) . if this passes , additionally makes sure the caller is allowed to interrupt each worker thread . this might not be true even if first check passed , if the securitymanager treats some threads specially .
