Number of idle {@link Executor}s that can start working immediately.
488827
@Exported
    public int getIdleExecutors() {
        int r=0;
        for (Node n : getNodes()) {
            Computer c = n.toComputer();
            if(c!=null && (c.isOnline() || c.isConnecting()) && c.isAcceptingTasks())
                r += c.countIdle();
        }
        return r;
    }
256408
@Exported
    public final boolean isIdle() {
        if (!oneOffExecutors.isEmpty())
            return false;
        for (Executor e : executors)
            if(!e.isIdle())
                return false;
        return true;
    }
565551
@Exported
    public int getBusyExecutors() {
        int r=0;
        for (Computer c : get_all()) {
            if(c.isOnline())
                r += c.countBusy();
        }
        return r;
    }
673031
public synchronized static ExecutorService getExecutorService() {
        if (executorService == null) {
            executorService = Executors.newCachedThreadPool();
            ((ThreadPoolExecutor) executorService).setMaximumPoolSize(executorPoolSize);
        }
        return executorService;
    }
250568
function idle() {
      if (!idleRunning) {
        idleRunning = true;
        requestIdleCallback(idleLoop, {timeout: next.maxIdle});
      }
      return create.apply(qidle, arguments);
    }
1002699
public static ExecutorService newSingleThreadDaemonExecutor() {
        return Executors.newSingleThreadExecutor(r -> {
            Thread t = Executors.defaultThreadFactory().newThread(r);
            t.setDaemon(true);
            return t;
        });
    }
719876
private synchronized void createExecutor() {
        if (componentConfig == null) {
            // this is a completely normal occurrence and can happen if a ThreadFactory is bound prior to
            // component activation...  the proper thing to do is to do nothing and wait for activation
            return;
        }

        if (threadPoolController != null)
            threadPoolController.deactivate();

        ThreadPoolExecutor oldPool = threadPool;

        poolName = (String) componentConfig.get("name");
        String threadGroupName = poolName + " Thread Group";

        int coreThreads = Integer.parseInt(String.valueOf(componentConfig.get("coreThreads")));
        int maxThreads = Integer.parseInt(String.valueOf(componentConfig.get("maxThreads")));

        if (maxThreads <= 0) {
            maxThreads = Integer.MAX_VALUE;
        }

        if (coreThreads < 0) {
            coreThreads = 2 * CpuInfo.getAvailableProcessors();
        }

        // Make sure coreThreads is not bigger than maxThreads, subject to MINIMUM_POOL_SIZE limit
        coreThreads = Math.max(MINIMUM_POOL_SIZE, Math.min(coreThreads, maxThreads));
        // ... and then make sure maxThreads is not smaller than coreThreads ...
        maxThreads = Math.max(coreThreads, maxThreads);

        BlockingQueue<Runnable> workQueue = new BoundedBuffer<Runnable>(java.lang.Runnable.class, 1000, 1000);

        RejectedExecutionHandler rejectedExecutionHandler = new ExpandPolicy(workQueue, this);

        threadPool = new ThreadPoolExecutor(coreThreads, maxThreads, 0, TimeUnit.MILLISECONDS, workQueue, threadFactory != null ? threadFactory : new ThreadFactoryImpl(poolName, threadGroupName), rejectedExecutionHandler);

        threadPoolController = new ThreadPoolController(this, threadPool);

        if (oldPool != null) {
            softShutdown(oldPool);
        }
    }
68190
public static ListeningExecutorService executor() {
        final ExecutorService svc = Executors.newCachedThreadPool(MoreExecutors.platformThreadFactory());
        return MoreExecutors.listeningDecorator(svc);
    }
411583
@Validate
    public void start() {
        Configuration conf = configuration.getConfiguration("pools");

        createExecutor(ManagedExecutorService.SYSTEM,
                conf != null ? conf.getConfiguration("executors." + ManagedExecutorService.SYSTEM) : null);
        createScheduler(ManagedScheduledExecutorService.SYSTEM,
                conf != null ? conf.getConfiguration("schedulers." + ManagedScheduledExecutorService.SYSTEM) : null);

        if (conf != null) {
            createOtherExecutors(conf.getConfiguration("executors"));
            createOtherSchedulers(conf.getConfiguration("schedulers"));
        }
    }
1157015
def start(self):
        
        if not self.started:
            self.started = True
            self.executor = ThreadPoolExecutor(max_workers=32)
            self.poller = self.executor.submit(self.poll_events)
        else:
            raise IllegalStateError("Dispatcher is already started.")
472137
public static void main(String[] args) throws InterruptedException {
		ExampleUtils.fillManagerWithSimons(100000);
		final ExecutorService executorService = Executors.newFixedThreadPool(1000);
		StopwatchSample[] results = BenchmarkUtils.run(1, 2,
			new BenchmarkUtils.Task("1") {
				@Override
				public void perform() throws Exception {
					new MultithreadedTester(TOTAL_TASK_RUNS, 1, executorService).execute();
				}
			},
			new BenchmarkUtils.Task("2") {
				@Override
				public void perform() throws Exception {
					new MultithreadedTester(TOTAL_TASK_RUNS, 2, executorService).execute();
				}
			},
			new BenchmarkUtils.Task("3") {
				@Override
				public void perform() throws Exception {
					new MultithreadedTester(TOTAL_TASK_RUNS, 3, executorService).execute();
				}
			},
			new BenchmarkUtils.Task("4") {
				@Override
				public void perform() throws Exception {
					new MultithreadedTester(TOTAL_TASK_RUNS, 4, executorService).execute();
				}
			},
			new BenchmarkUtils.Task("5") {
				@Override
				public void perform() throws Exception {
					new MultithreadedTester(TOTAL_TASK_RUNS, 5, executorService).execute();
				}
			},
			new BenchmarkUtils.Task("100") {
				@Override
				public void perform() throws Exception {
					new MultithreadedTester(TOTAL_TASK_RUNS, 100, executorService).execute();
				}
			}
		);
		executorService.shutdown();

		System.out.println("\nGoogle Chart avg:\n" +
			GoogleChartImageGenerator.barChart("Multithreaded test", results));
	}
242444
@Override
    public void run() {
        if (!stateUpdater.compareAndSet(this, 1, 2)) {
            return;
        }

        List<JDBCLogAttribute> messages = new ArrayList<>();
        JDBCLogAttribute msg = null;

        //only grab at most 1000 messages at a time
        for (int i = 0; i < 1000; ++i) {
            msg = pendingMessages.poll();
            if (msg == null) {
                break;
            }
            messages.add(msg);
        }
        try {
            if (!messages.isEmpty()) {
                writeMessage(messages);
            }
        } finally {
            Executor executor = this.executor;
            stateUpdater.set(this, 0);
            //check to see if there is still more messages
            //if so then run this again
            if (!pendingMessages.isEmpty()) {
                if (stateUpdater.compareAndSet(this, 0, 1)) {
                    executor.execute(this);
                }
            }
        }
    }
1118412
public int getIdleExecutors() {
        int r=0;
        for (Computer c : get_all())
            if((c.isOnline() || c.isConnecting()) && c.isAcceptingTasks())
                r += c.countIdle();
        return r;
    }
816773
private void startupProcessor() {
        Processor processor = processorRef.get();
        if (processor == null) {
            processor = new Processor();
            if (processorRef.compareAndSet(null, processor)) {
                executor.execute(new NamePreservingRunnable(processor,
                        threadName));
            }
        }

        // Just stop the select() and start it again, so that the processor
        // can be activated immediately. 
        wakeup();
    }
1037458
def run(self):
        """"""

        idle_watchers = []

        while True:
            try:
                if self._work_queue.empty() and len(idle_watchers) > 0:
                    for watcher in idle_watchers:
                        try:
                            watcher()
                        except: # pylint:disable=bare-except;We can't let one idle watcher failure impact any other watcher
                            self._logger.exception("Error inside queue idle watcher")

                    idle_watchers = []

                item = self._work_queue.get()

                # Handle special actions that are not RPCs
                if item is STOP_WORKER_ITEM:
                    return
                elif isinstance(item, MarkLocationItem):
                    item.callback()
                    continue
                elif isinstance(item, WaitIdleItem):
                    idle_watchers.append(item.callback)
                    continue
                elif not isinstance(item, WorkItem):
                    self._logger.error("Invalid item passed to WorkQueueThread: %s, ignoring", item)
                    continue

                self.direct_dispatch(item.arg, item.callback)

            except:  # pylint:disable=bare-except;We cannot let this background thread die until we are told to stop()
                self._logger.exception("Error inside background workqueue thread")
173438
private void createAndExecuteTasks(Executor executor, ProcedureFactory<BT> procedureFactory, T[] array)
    {
        this.procedures = new ArrayProcedureFJTask[this.taskCount];
        int sectionSize = array.length / this.taskCount;
        int size = this.taskCount;
        for (int index = 0; index < size; index++)
        {
            ArrayProcedureFJTask<T, BT> procedureFJTask = new ArrayProcedureFJTask<T, BT>(this, procedureFactory, array, index,
                    sectionSize, index == this.taskCount - 1);
            this.procedures[index] = procedureFJTask;
            executor.execute(procedureFJTask);
        }
    }
188607
protected void startQueue() {
      if (executor == null) {
          logger.debug("Starting the receiving thread pool.");
          executor = new ThreadPoolExecutor(
                  numberOfWorkerThreads,
                  numberOfWorkerThreads,
                  threadKeepAliveTime, TimeUnit.SECONDS,
                  new LinkedBlockingQueue<Runnable>(),
                  getThreadFactory());
          executor.allowCoreThreadTimeOut(true);
          //Start with one thread, and build it up gradually as it needs.
          executor.prestartCoreThread();
          logger.info("ReceiveQueue started! Current pool size: {}", executor.getPoolSize());
      } else {
          if (executor.getCorePoolSize() < numberOfWorkerThreads) {
              //If the number has increased we need to set the max first, or we'll get an IllegalArgumentException
              executor.setMaximumPoolSize(numberOfWorkerThreads);
              executor.setCorePoolSize(numberOfWorkerThreads);
          } else if (executor.getCorePoolSize() > numberOfWorkerThreads) {
              //If the number has decreased we need to set the core first.
              executor.setCorePoolSize(numberOfWorkerThreads);
              executor.setMaximumPoolSize(numberOfWorkerThreads);
          }
          logger.info("ReceiveQueue running. Current pool size: {}. Current Queue size: {}",
                  executor.getPoolSize(), getQueueSize());
          logger.info("Nr of active pool-threads: {}", executor.getActiveCount());
      }
    }