Interrupt all {@link Executor}s.
Called from {@link Jenkins#cleanUp}.
185204
public void interrupt() {
        Queue.withLock(new Runnable() {
            @Override
            public void run() {
                for (Executor e : executors) {
                    e.interruptForShutdown();
                }
            }
        });
    }
742906
private static void shutdown(ExecutorService executorService) {
        executorService.shutdown();
        try {
            if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
                executorService.shutdownNow();
                if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
                    System.err.println("Thread pool did not terminate");
                }
            }
        } catch (InterruptedException ie) {
            executorService.shutdownNow();
            Thread.currentThread().interrupt();
        }
    }
98333
public ServiceBroker stop() {

		// Stop internal components
		stop(transporter);
		stop(serviceRegistry);
		stop(eventbus);
		stop(serviceInvoker);
		stop(contextFactory);
		stop(strategyFactory);
		stop(uidGenerator);

		// Shutdown thread pools
		if (config.isShutDownThreadPools()) {
			ExecutorService executor = config.getExecutor();
			if (executor != null && !executor.isShutdown() && !executor.isTerminated()) {
				try {
					executor.shutdownNow();
				} catch (Exception ignored) {
				}
			}
			logger.info("Task Executor Service stopped.");
			ScheduledExecutorService scheduler = config.getScheduler();
			if (scheduler != null && !scheduler.isShutdown() && !scheduler.isTerminated()) {
				try {
					scheduler.shutdownNow();
				} catch (Exception ignored) {
				}
			}
			logger.info("Task Scheduler Service stopped.");
		}
		return this;
	}
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);
            }
        }
    }
675726
def shutdown(self):
        """"""
        self._done.set()
        self.executor.shutdown(wait=False)
167057
public void stop() throws InterruptedException
    {
        synchronized (this)
        {
            // Signal that we are stopping
            _running = false;

            // Close the listener socket.
            if (log.isDebugEnabled()) log.debug("closing " + _listen);
            try
            {
                if (_listen != null) _listen.close();
                _listen=null;
            }
            catch (IOException e)
            {
                log.warn(LogSupport.EXCEPTION, e);
            }

            // Do we have an acceptor thread (running or not)
            Thread.yield();
            for (int a = 0; _acceptor!=null && a<_acceptor.length; a++)
            {
                Acceptor acc = _acceptor[a];
                if (acc != null) 
                    acc.interrupt();
            }
            Thread.sleep(100);

            for (int a = 0; _acceptor!=null && a<_acceptor.length; a++)
            {
                Acceptor acc = _acceptor[a];

                if (acc != null)
                {
                    acc.forceStop();
                    _acceptor[a] = null;
                }
            }
        }

        // Stop the thread pool
        try
        {
            super.stop();
        }
        catch (Exception e)
        {
            log.warn(LogSupport.EXCEPTION, e);
        }
        finally
        {
            synchronized (this)
            {
                _acceptor = null;
            }
        }
    }
1030117
public void shutdown() {
        executorService.shutdown();
        scheduler.shutdown();
        daemonScheduler.shutdown();
        executorServiceSingleThreads.values().forEach(ExecutorService::shutdown);
    }
1254294
public static void shutdownAndAwaitTermination() {
		shutdown();
		if (pool != null) {
			try {
				// wait a while for existing tasks to terminate
				if (!pool.awaitTermination(60L, TimeUnit.SECONDS)) {
					pool.shutdownNow(); // cancel currently executing tasks
					// wait a while for tasks to respond to being canceled
					if (!pool.awaitTermination(60L, TimeUnit.SECONDS)) {
						logger.warn("BioJava ConcurrencyTools thread pool did not terminate");
					}
				}
			} catch (InterruptedException ie) {
				pool.shutdownNow(); // (re-)cancel if current thread also interrupted
				Thread.currentThread().interrupt(); // preserve interrupt status
			}
		}
	}
1155184
@Override
    public void close() {
        synchronized (startedTasks) {
            if (executor.isShutdown()) {
                return;
            }
            // ... stop updater thread. Do not interrupt.
            executor.shutdown();
            try {
                updater.get();
            } catch (InterruptedException | CancellationException | ExecutionException ignore) {
                // Ignore these closing thread errors.
            }
            // And stop all the tasks, do interrupting.
            for (InternalTask task : startedTasks) {
                task.cancel(true);
            }
            for (InternalTask task : queuedTasks) {
                task.close();
            }

            try {
                executor.awaitTermination(100L, TimeUnit.MILLISECONDS);
            } catch (InterruptedException ignore) {
                Thread.currentThread().interrupt();
            }
        }
    }
778650
@Handler(priority = -10000)
    public void onStop(Stop event) throws InterruptedException {
        synchronized (this) {
            if (runner == null) {
                return;
            }
            runner.interrupt();
            synchronized (this) {
                if (registered) {
                    unregisterAsGenerator();
                    registered = false;
                }
            }
            runner = null;
        }
    }
600787
public synchronized final void stop()
    	throws InterruptedException
    {
        if (!_started || _stopping)
            return;
        _stopping=true;

        if (log.isDebugEnabled()) log.debug("Stopping "+this);
        LifeCycleEvent event = new LifeCycleEvent(this);
        for(int i=0;i<LazyList.size(_eventListeners);i++)
        {
            EventListener listener=(EventListener)LazyList.get(_eventListeners,i);
            if (listener instanceof LifeCycleListener)
                ((LifeCycleListener)listener).lifeCycleStopping(event);
        }
        
        try
        {	
            doStop();
            _started=false;
            log.info("Stopped "+this);
            for(int i=0;i<LazyList.size(_eventListeners);i++)
            {
                EventListener listener=(EventListener)LazyList.get(_eventListeners,i);
                if (listener instanceof LifeCycleListener)
                    ((LifeCycleListener)listener).lifeCycleStopped(event);
            }
        }
        catch(Throwable e)
        {
            event = new LifeCycleEvent(this,e);
            for(int i=0;i<LazyList.size(_eventListeners);i++)
            {
                EventListener listener=(EventListener)LazyList.get(_eventListeners,i);
                if (listener instanceof LifeCycleListener)
                    ((LifeCycleListener)listener).lifeCycleFailure(event);
            }
            if (e instanceof InterruptedException)
                throw (InterruptedException)e;
            if (e instanceof RuntimeException)
                throw (RuntimeException)e;
            if (e instanceof Error)
                throw (Error)e;
            log.warn(LogSupport.EXCEPTION, e);
        }
        finally
        {
            _stopping=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");
    }
  }
1134886
public void stop() throws Throwable
   {
      shutdown.set(true);

      if (!isExternal && executorService != null)
      {
         executorService.shutdownNow();
         executorService = null;
      }

      registeredPools.clear();
   }
39251
@Invalidate
    public void stop() throws InterruptedException {
        unregisterQuietly(vertxRegistration);
        unregisterQuietly(busRegistration);
        CountDownLatch latch = new CountDownLatch(1);
        vertx.close(v -> latch.countDown());
        latch.await();
        vertx = null;
    }
56339
public void stop() {
    if (runnerThread == null) {
      return;
    }

    runnerThread.interrupt();

    nsLock.writeLock().lock();
    try {
      if (runnerThread == null) {
        return;
      }

      this.cancel();
      this.close();

      while (runnerThread.isAlive()) {
        runnerThread.interrupt();
        try {
          runnerThread.join(1000);
        } catch (final Exception e) {
          e.printStackTrace();
          return;
        }
      }
      runnerThread = null;
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      nsLock.writeLock().unlock();
    }
  }
535710
public void terminate() throws InterruptedException, IOException {
        final Computer computer = toComputer();
        if (computer != null) {
            computer.recordTermination();
        }
        try {
            // TODO: send the output to somewhere real
            _terminate(new StreamTaskListener(System.out, Charset.defaultCharset()));
        } finally {
            try {
                Jenkins.get().removeNode(this);
            } catch (IOException e) {
                LOGGER.log(Level.WARNING, "Failed to remove "+name,e);
            }
        }
    }
1238027
@Override
  public void stop() {
    cancellable.cancel();

    for (final SocketChannelSelectionProcessor processor : processors) {
      processor.close();
    }

    try {
      selector.close();
    } catch (Exception e) {
      logger().log("Failed to close selctor for: '" + name + "'", e);
    }

    try {
      channel.close();
    } catch (Exception e) {
      logger().log("Failed to close channel for: '" + name + "'", e);
    }

    super.stop();
  }