Returns the thread idle max.
357259
public void setIdleMax(int idleMax)
  {
    if (idleMax <= _idleMin) {
      throw new IllegalArgumentException(L.l("idle-max '{0}' must be greater than idle-min '{1}'.",
                                             idleMax, _idleMin));
    }

    _launcher.setIdleMax(_idleMax);
  }
395653
public int getRunningThreadCount() {
        int rc = 0;
        WorkQueue[] ws; WorkQueue w;
        if ((ws = workQueues) != null) {
            for (int i = 1; i < ws.length; i += 2) {
                if ((w = ws[i]) != null && w.isApparentlyUnblocked())
                    ++rc;
            }
        }
        return rc;
    }
924563
public int getThreadNumber() {
        if (cli.hasOption(THREAD_NUMBER)) {
            return Integer.valueOf(cli.getOptionValue(THREAD_NUMBER));
        }

        return DEFAULT_THREAD_NUMBER;
    }
216342
def get(cls):
        
        stats = {}
        cur_time = time.time()
        # minimum interval for getting CPU and memory statistics
        if cur_time < cls._last_measurement or \
           cur_time > cls._last_measurement + 1.9:
            cls._last_measurement = cur_time
            # Non blocking call to get cpu usage. First call will return 0
            cls._last_cpu_percent = psutil.cpu_percent(interval=None)
            cls._last_mem_percent = psutil.virtual_memory().percent
        stats["cpu_usage_percent"] = cls._last_cpu_percent
        stats["memory_usage_percent"] = cls._last_mem_percent
        return stats
612453
IOThread chooseIoThread(long affinity)
    {
        if (ioThreads.isEmpty()) {
            return null;
        }

        //  Find the I/O thread with minimum load.
        int minLoad = -1;
        IOThread selectedIoThread = null;

        for (int i = 0; i != ioThreads.size(); i++) {
            if (affinity == 0 || (affinity & (1L << i)) > 0) {
                int load = ioThreads.get(i).getLoad();
                if (selectedIoThread == null || load < minLoad) {
                    minLoad = load;
                    selectedIoThread = ioThreads.get(i);
                }
            }
        }
        return selectedIoThread;
    }
1171007
def get_last_thread(self):
        
        cache_key = '_get_last_thread_cache'
        if not hasattr(self, cache_key):
            item = None
            res = self.thread_set.filter(visible=True).order_by('-modified')[0:1]
            if len(res)>0:
                item = res[0]
            setattr(self, cache_key, item)
        return getattr(self, cache_key)
1041810
public int getIdleThreads()
   {
      if (executor instanceof ThreadPoolExecutor)
      {
         final ThreadPoolExecutor tpe = (ThreadPoolExecutor)executor;
         return tpe.getPoolSize() - tpe.getActiveCount();
      }
      return -1;
   }
712754
def _idle_loop(self):
        
        while not self._stop_update_flag:
            time.sleep(self.update_interval)
            with self.update_lock:
                try:
                    self.idle()
                except:
                    self._log.error("exception in App.idle method", exc_info=True)
                if self._need_update_flag:
                    try:
                        self.do_gui_update()
                    except:
                        self._log.error('''exception during gui update. It is advisable to 
                            use App.update_lock using external threads.''', exc_info=True)
54923
def getWindowPID(self, hwnd):
        
        pid = ctypes.c_ulong()
        ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
        return int(pid.value)
1161011
public double getElapsedTimeCurrentThread(int stage) {
	   if (stage == ProfilingEvent.START.ordinal()) {
           return 0;    
	   }
	   
	   Accumulator acc = getAccForThread();

	   return acc == null ? Double.NaN : (acc.currentTimes[stage] - acc.currentTimes[stage - 1]) / MILLION;
   }
30578
public T getMaximum() {
        Lock lock = this.lock.readLock();
        lock.lock();
        try {
            return this.maximum;
        } finally {
            lock.unlock();
        }
    }
494071
public int getThreadCount(ThreadGroup group, Status... s) {
        Thread[] threads = getThreads(group);
        int count = 0;
        for (Thread t : threads) {
            if (t instanceof MonitoredThread) {
                Status status = getStatus((MonitoredThread) t);
                if (status != null) {
                    for (Status x : s) {
                        if (x == status) {
                            count++;
                        }
                    }
                }
            }
        }
        return count;
    }
159298
public int getActiveCount() {
        final ReentrantLock mainLock = this.mainLock;
        mainLock.lock();
        try {
            int n = 0;
            for (Worker w : workers)
                if (w.isLocked())
                    ++n;
            return n;
        } finally {
            mainLock.unlock();
        }
    }
995780
private int defaultThreadID() {
        long tid = Thread.currentThread().getId();
        if (tid < MIN_SEQUENTIAL_THREAD_ID) {
            return (int) tid;
        } else {
            Integer id = threadIds.get();
            if (id == null) {
                id = nextThreadId.getAndIncrement();
                threadIds.set(id);
            }
            return id;
        }
    }
250568
function idle() {
      if (!idleRunning) {
        idleRunning = true;
        requestIdleCallback(idleLoop, {timeout: next.maxIdle});
      }
      return create.apply(qidle, arguments);
    }
1006822
int keepaliveThreadRead(ReadStream is, long timeoutConn)
    throws IOException
  {
    if (isClosed()) {
      return -1;
    }

    int available = is.availableBuffer();

    if (available > 0) {
      return available;
    }

    long timeout = Math.min(getKeepaliveTimeout(), getSocketTimeout());
    
    if (timeoutConn > 0) {
      timeout = Math.min(timeout, timeoutConn);
    }

    // server/2l02
    int keepaliveThreadCount = _keepaliveThreadCount.incrementAndGet();

    // boolean isSelectManager = getServer().isSelectManagerEnabled();

    try {
      int result;

      if (isKeepaliveAsyncEnabled() && _pollManager != null) {
        timeout = Math.min(timeout, getBlockingTimeoutForPoll());

        if (keepaliveThreadCount > 32) {
          // throttle the thread keepalive when heavily loaded to save threads
          if (isAsyncThrottle()) {
            // when async throttle is active move the thread to async
            // immediately
            return 0;
          }
          else {
            timeout = Math.min(timeout, 100);
          }
        }
      }

      /*
      if (timeout < 0)
        timeout = 0;
        */

      if (timeout <= 0) {
        return 0;
      }

      _keepaliveThreadMeter.start();

      try {
        /*
        if (false && _keepaliveThreadCount.get() < 32) {
          // benchmark perf with memcache
          result = is.fillWithTimeout(-1);
        }
        */

        result = is.fillWithTimeout(timeout);
      } finally {
        _keepaliveThreadMeter.end();
      }

      if (isClosed()) {
        return -1;
      }

      return result;
    } catch (IOException e) {
      if (isClosed()) {
        log.log(Level.FINEST, e.toString(), e);

        return -1;
      }

      throw e;
    } finally {
      _keepaliveThreadCount.decrementAndGet();
    }
  }
1086691
public SchedulerStats stats() {
		int activeThreads = threadPoolExecutor.getActiveCount();
		return SchedulerStats.of(ThreadPoolStats.of(
			threadPoolExecutor.getCorePoolSize(),
			threadPoolExecutor.getMaximumPoolSize(),
			activeThreads,
			threadPoolExecutor.getPoolSize() - activeThreads,
			threadPoolExecutor.getLargestPoolSize()
		));
	}