Is the pool low on threads ?
@return True if active threads >= maximum number of threads
497302
public boolean isLowOnThreads()
   {
      if (executor instanceof ThreadPoolExecutor)
      {
         final ThreadPoolExecutor tpe = (ThreadPoolExecutor)executor;
         return tpe.getActiveCount() >= tpe.getMaximumPoolSize();
      }
      return false;
   }
1027915
private void balance() {
        // only try to balance when we're not terminating
        if(!isTerminated()) {
            Set<Map.Entry<Thread, Tracking>> threads = liveThreads.entrySet();
            long liveAvgTimeTotal = 0;
            long liveAvgCpuTotal = 0;
            long liveCount = 0;
            for (Map.Entry<Thread, Tracking> e : threads) {
                if (!e.getKey().isAlive()) {
                    // thread is dead or otherwise hosed
                    threads.remove(e);
                } else {
                    liveAvgTimeTotal += e.getValue().avgTotalTime;
                    liveAvgCpuTotal += e.getValue().avgCpuTime;
                    liveCount++;
                }
            }
            long waitTime = 1;
            long cpuTime = 1;
            if(liveCount > 0) {
                waitTime = liveAvgTimeTotal / liveCount;
                cpuTime = liveAvgCpuTotal / liveCount;
            }

            int size = 1;
            if(cpuTime > 0) {
                size = (int) ceil((CPUS * targetUtilization * (1 + (waitTime / cpuTime))));
            }
            size = Math.min(size, threadPoolExecutor.getMaximumPoolSize());

            // TODO remove debugging
            //System.out.println(waitTime / 1000000 + " ms");
            //System.out.println(cpuTime / 1000000 + " ms");
            //System.out.println(size);

            threadPoolExecutor.setCorePoolSize(size);
        }
    }
1367743
def is_full(cls, pid):
        
        with cls._lock:
            cls._ensure_pool_exists(pid)
            return cls._pools[pid].is_full
1146692
public boolean isSingleMember() {
		final Address localAddress = getLocalAddress();
		if (localAddress != null) {
			final List<Address> clusterMembers = getClusterMembers();
			return clusterMembers.size() == 1;
		}
		else {
			return true;
		}
	}
923826
def run_with_threads
      thread_pool.gather_history if options.job_stats == :history

      yield

      thread_pool.join
      if options.job_stats
        stats = thread_pool.statistics
        puts "Maximum active threads: #{stats[:max_active_threads]}"
        puts "Total threads in play:  #{stats[:total_threads_in_play]}"
      end
      ThreadHistoryDisplay.new(thread_pool.history).show if
        options.job_stats == :history
    end
426728
public boolean limit() {

        //get connection
        Object connection = getConnection();

        Object result = limitRequest(connection);

        if (FAIL_CODE != (Long) result) {
            return true;
        } else {
            return false;
        }
    }
118172
private boolean mainLoop()
        throws InterruptedException
    {
        long now = System.currentTimeMillis();
        Iterator list = m_hardStore.values().iterator();
        while( list.hasNext() )
        {
            Entry entry = (Entry) list.next();
            if( entry.m_collectTime < now )
            {
                m_weakStore.put( entry.m_connection, DUMMY );
                list.remove();
            }
        }
        if( m_hardStore.size() == 0 )
        {
            m_thread = null;    // mark to start a new thread next time.
            return true;
        }
        wait( 10000 );
        return false;
    }
900238
public boolean isTerminated() {
		final Thread executingThread = this.environment.getExecutingThread();
		if (executingThread.getState() == Thread.State.TERMINATED) {
			return true;
		}

		return false;
	}
756713
private boolean checkForActiveConnections(int value) {
        /*
         * Check for active connections in the SharedPool
         */
        boolean activeConnections = false;

        /*
         * We have active connections or active pool requests if active requests
         * > 0 or the pool state is not = 1. In either case, we will consider the
         * pool active if statement is true.
         */
        if (value == 0) {
            mcToMCWMapWrite.lock();
            try {
                Collection<MCWrapper> mcWrappers = mcToMCWMap.values();
                Iterator<MCWrapper> mcWrapperIt = mcWrappers.iterator();
                while (mcWrapperIt.hasNext()) {
                    MCWrapper mcw = mcWrapperIt.next();
                    /*
                     * We have atleast one active connection.
                     */
                    /*
                     * If the value is zero, both tests are used.
                     */
                    if (activeRequest.get() > 0) {
                        activeConnections = true;
                        break;
                    } else {
                        int poolState = mcw.getPoolState();
                        if ((poolState != 1) && (poolState != 9)) {
                            activeConnections = true;
                            break;
                        }
                    }
                }
            } finally {
                mcToMCWMapWrite.unlock();
            }
        } else {
            /*
             * Only activeRequest is used.
             */
            if (activeRequest.get() > 0) {
                activeConnections = true;
            }
        }

        return activeConnections;
    }
1178851
@Override
    public boolean hasRemaining() {
        if (isFCEnabled()) {
            int remaining = this.fcLimit - position();
            if (remaining < 0) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "hasRmeaining, less than 0");
                }
                RuntimeException rte = new RuntimeException("FCWsByteBufferImpl.hasRemaining(): value is less than 0");
                FFDCFilter.processException(rte, CLASS_NAME + ".hasRemaining()", "1115", this);
                throw rte;
            }
            return (remaining > 0);
        }
        return super.hasRemaining();
    }
610287
protected boolean doStart()
  {
    if (! _lifecycle.isActive()) {
      return false;
    }
    
    if (! isEnable()) {
      return false;
    }
    
    int startingCount = _startingCount.getAndIncrement();

    int threadCount = _threadCount.get() + startingCount;

    if (_threadMax < threadCount) {
      _startingCount.decrementAndGet();
      
      onThreadMax();
      
      return false;
    }
    else if (isIdleTooLow(startingCount)) {
      return true;
    }
    else {
      _startingCount.decrementAndGet();
      
      return false;
    }
  }
1086691
public SchedulerStats stats() {
		int activeThreads = threadPoolExecutor.getActiveCount();
		return SchedulerStats.of(ThreadPoolStats.of(
			threadPoolExecutor.getCorePoolSize(),
			threadPoolExecutor.getMaximumPoolSize(),
			activeThreads,
			threadPoolExecutor.getPoolSize() - activeThreads,
			threadPoolExecutor.getLargestPoolSize()
		));
	}
1087402
public int getMaxQueuedConnections() {
	return getThreadPool() == null ? -1 :
	    ((getThreadPool().getQueue() instanceof ArrayBlockingQueue) ?
	     ((ArrayBlockingQueue)getThreadPool().getQueue()).size() +
	     ((ArrayBlockingQueue)getThreadPool().getQueue()).remainingCapacity() : -1);	     
    }
748610
public final int getActiveConnectionCount() {

      if(!isActive) {
         return 0;
      }

      int count = 0;
      for(ConnectionPoolConnection conn : connections) {
         if(conn.state.get() != ConnectionPoolConnection.STATE_AVAILABLE) {
            count++;
         }
      }

      return count;
   }
384928
private boolean isTrivialStackOps() {

        int invokeCount = 0;
        for (ActiveStackOp op : activeStackOps) {
            if (INVOKE_OPS.get(op.getOpcode())) {
                invokeCount++;
            }
        }

        if (invokeCount == 1) {
            FQMethod method = activeStackOps.getLast().getMethod();
            if (method == null) {
                return false;
            }

            if ("valueOf".equals(method.getMethodName()) && method.getClassName().startsWith("java/lang/")) {
                return true;
            }
        }

        // do simple string appending?

        return false;
    }
646288
public void purgeThreadLocal() {
        // if thread local pools exist, check to see if we have one created and
        // therefore need to tell it to purge
        if (null != threadLocals) {
            LocalThreadObjectPool pool = threadLocals.get();
            if (null != pool) {
                Object[] data = pool.purge();
                if (0 < data.length) {
                    mainPool.putBatch(data);
                }
            }
        }
    }
1044486
int adjustPoolSize(int poolSize, int poolAdjustment) {
        if (threadPool == null)
            return poolSize; // arguably should return 0, but "least change" is safer... This happens during shutdown.

        int newPoolSize = poolSize + poolAdjustment;
        lastAction = LastAction.NONE;

        if (poolAdjustment != 0) {
            // don't shrink below coreThreads
            if (poolAdjustment < 0 && newPoolSize >= coreThreads) {
                lastAction = LastAction.SHRINK;
                setPoolSize(newPoolSize);
            } else if (poolAdjustment > 0 && newPoolSize <= maxThreads) {
                lastAction = LastAction.GROW;
                setPoolSize(newPoolSize);
            } else {
                newPoolSize = poolSize;
            }
        }

        return newPoolSize;
    }