shutdown executor threads
199322
public void shutdown() {
        // shutdown each single thread executor in the managed collection
        for (ExecutorService singleThreadExecutorService : singleThreadExecutorServices) {
            shutdownExecutor(singleThreadExecutorService);
        }

        // shutdown scheduled executor instance
        shutdownExecutor(getInternalScheduledExecutorService());
        shutdownExecutor(getInternalGpioExecutorService());

    }
1327885
public final synchronized void shutdown() {  // synchronize on 'this' to avoid races with registerStreams
        stopped = true;
        // If the cleanup task is running tell it to stop looping, and then remove it from the scheduled executor
        if (cleanupTaskFuture != null) {
            cleanupTaskFuture.cancel(false);
        }

        // Close remaining streams
        for (Map.Entry<InputStreamKey, TimedStreamEntry> entry : streamMap.entrySet()) {
            InputStreamKey key = entry.getKey();
            TimedStreamEntry timedStreamEntry = entry.getValue();
            //noinspection SynchronizationOnLocalVariableOrMethodParameter
            synchronized (timedStreamEntry) { // ensure there's no race with a request that got a ref before we removed it
                closeStreamEntry(timedStreamEntry, key.requestId, key.index);
            }
        }
    }
320403
public void shutdownAndWait() {
        executor.shutdown();
        try {
            executor.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); // forever
        } catch (InterruptedException x) {
            throw new RuntimeException(x);
        }
    }
1235825
@Invalidate
    public void stop() {
        for (Map.Entry<ServiceRegistration, ExecutorService> entry : instances.entrySet()) {
            entry.getKey().unregister();
            entry.getValue().shutdownNow();
        }
        instances.clear();
    }
1004035
public void shutdown() {
    logger.warn("Shutting down FlowRunnerManager...");
    if (this.azkabanProps.getBoolean(ConfigurationKeys.AZKABAN_POLL_MODEL, false)) {
      this.pollingService.shutdown();
    }
    this.executorService.shutdown();
    boolean result = false;
    while (!result) {
      logger.info("Awaiting Shutdown. # of executing flows: " + getNumRunningFlows());
      try {
        result = this.executorService.awaitTermination(1, TimeUnit.MINUTES);
      } catch (final InterruptedException e) {
        logger.error(e);
      }
    }
    logger.warn("Shutdown FlowRunnerManager complete.");
  }
1121151
public void stop() {
        if (shutdownExecutorOnStop) {
            executor.shutdown(); // Disable new tasks from being submitted
            try {
                // Wait a while for existing tasks to terminate
                if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
                    executor.shutdownNow(); // Cancel currently executing tasks
                    // Wait a while for tasks to respond to being cancelled
                    if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
                        System.err.println(getClass().getSimpleName() + ": ScheduledExecutorService did not terminate");
                    }
                }
            } catch (InterruptedException ie) {
                // (Re-)Cancel if current thread also interrupted
                executor.shutdownNow();
                // Preserve interrupt status
                Thread.currentThread().interrupt();
            }
        } else {
            // The external manager(like JEE container) responsible for lifecycle of executor
            synchronized (this) {
                if (this.scheduledFuture == null) {
                    // was never started
                    return;
                }
                if (this.scheduledFuture.isCancelled()) {
                    // already cancelled
                    return;
                }
                // just cancel the scheduledFuture and exit
                this.scheduledFuture.cancel(false);
            }
        }
    }
1072725
synchronized void shutdown() {
    
    if (executors == null) {
      
      LOG.warn("AsyncDiskService has already shut down.");
      
    } else {
      LOG.info("Shutting down all async disk service threads...");
      
      for (Map.Entry<File, ThreadPoolExecutor> e
          : executors.entrySet()) {
        e.getValue().shutdown();
      }
      // clear the executor map so that calling execute again will fail.
      executors = null;
      
      LOG.info("All async disk service threads have been shut down.");
    }
  }
675726
def shutdown(self):
        """"""
        self._done.set()
        self.executor.shutdown(wait=False)
379507
public void stop() {
    ScheduledExecutorService service = executor.get();
    if (service != null && executor.compareAndSet(service, null)) {
      service.shutdown();
    } else {
      throw new IllegalStateException("scheduler must be started before you stop it");
    }
  }
155329
@Override public void shutdown() {
        if (isStarted()) {
            future.cancel(true);
            executorService.shutdown();
            future = null;
            executorService = null;
            watchedFiles = ImmutableSet.of();
            callback = null;
            metadataCacheRef.set(ImmutableMap.of());
            stats.clear();
        }
    }
48721
def kill_threads(self):
    """"""
    self._terminate.set()
    while self.are_threads_alive():
      time.sleep(0.001)
    self._threads = ()
    return self
903935
def shutdown(self):
        
        self.run_clean_thread = False
        self.cleanup(True)
        if self.cleaner_thread.isAlive():
            self.cleaner_thread.join()
821995
public void shutdown() {
        final ReentrantLock mainLock = this.mainLock;
        mainLock.lock();
        try {
            /* J2ObjC removed.
            checkShutdownAccess();
            */
            advanceRunState(SHUTDOWN);
            interruptIdleWorkers();
            onShutdown(); // hook for ScheduledThreadPoolExecutor
        } finally {
            mainLock.unlock();
        }
        tryTerminate();
    }
459352
private void shutdownExecutorGroups(long quietPeriod, long timeout, TimeUnit unit, EventExecutorGroup...groups) {
    Exception ex = null;
    List<Future<?>> futures = new ArrayList<>();
    for (EventExecutorGroup group : groups) {
      if (group == null) {
        continue;
      }
      futures.add(group.shutdownGracefully(quietPeriod, timeout, unit));
    }

    for (Future<?> future : futures) {
      try {
        future.syncUninterruptibly();
      } catch (Exception e) {
        if (ex == null) {
          ex = e;
        } else {
          ex.addSuppressed(e);
        }
      }
    }

    if (ex != null) {
      // Just log, don't rethrow since it shouldn't happen normally and
      // there is nothing much can be done from the caller side
      LOG.warn("Exception raised when shutting down executor", ex);
    }
  }
766798
public void shutdown() {
        if (workers == null) {
            if (LOGGER.isLoggable(Level.INFO))
                LOGGER.info(name + " already been shutdown");
            return;
        }

        if (LOGGER.isLoggable(Level.INFO))
            LOGGER.info("Starting shutdown " + name);

        for (final Thread worker : workers) {
            worker.interrupt();
            try {
                worker.join();
            } catch (InterruptedException exception) {
                Thread.currentThread().interrupt();
            }
        }
        workers = null;

        TcpServerHandler handler;
        while ((handler = handlers.poll()) != null) handler.destroy();
        handlers = null;

        if (LOGGER.isLoggable(Level.INFO))
            LOGGER.info(name + " was shutdown");
    }
1191079
public static void shutdown() {
        try {
            EXECUTOR_SERVICE.shutdown();

            if (RuntimeCache.REDIS == getRuntimeCache()) {
                RedisCache.shutdown();
            }

            Connections.shutdownConnectionPool();
            if (RuntimeDatabase.H2 == getRuntimeDatabase()) {
                final String newTCPServer = getLocalProperty("newTCPServer");
                if ("true".equals(newTCPServer)) {
                    h2.stop();
                    h2.shutdown();

                    LOGGER.log(Level.INFO, "Closed H2 TCP server");
                }
            }
        } catch (final Exception e) {
            LOGGER.log(Level.ERROR, "Shutdowns Latke failed", e);
        }

        BeanManager.close();

        // Manually unregister JDBC driver, which prevents Tomcat from complaining about memory leaks
        final Enumeration<Driver> drivers = DriverManager.getDrivers();
        while (drivers.hasMoreElements()) {
            final Driver driver = drivers.nextElement();

            try {
                DriverManager.deregisterDriver(driver);
                LOGGER.log(Level.TRACE, "Unregistered JDBC driver [" + driver + "]");
            } catch (final SQLException e) {
                LOGGER.log(Level.ERROR, "Unregister JDBC driver [" + driver + "] failed", e);
            }
        }
    }
1357472
public void stop() {
        if (!this.isActive) {
            return;
        }

        cpuThread.shutdown();

        try {
            Thread.sleep(40);
        } catch (InterruptedException e) {
        }

        for (int i = 0; i < taskQueues.length; i++)
            taskQueues[i].clear();

        heartBeatQueue.clear();
    }