Code example for ThreadPoolExecutor

Methods: getActiveCountgetMaximumPoolSizegetPoolSizeisShutdownisTerminatedisTerminating

0
	 * @see java.util.concurrent.RejectedExecutionHandler#rejectedExecution(java.lang.Runnable, 
	 *      java.util.concurrent.ThreadPoolExecutor) 
	 */ 
 
	public void rejectedExecution(final Runnable runnable, final ThreadPoolExecutor executor) {
		if (executor.isShutdown() || executor.isTerminated() || executor.isTerminating()) {
			LOG.trace("El executor de tareas rechazó el runnable: " + runnable + " después de ser detenido");
			return; 
		} 
 
		final int maximunSize = executor.getMaximumPoolSize();
		final int poolSize = executor.getPoolSize();
		final boolean noEstaAlLimiteDeThreads = poolSize < maximunSize;
 
		final int activeCount = executor.getActiveCount();
		final boolean noEstaProcesandoTareas = activeCount == 0;
 
		final boolean deberiaEstarAceptandoTareas = noEstaAlLimiteDeThreads && noEstaProcesandoTareas;
		if (deberiaEstarAceptandoTareas) {
			LOG.debug("El executor de tareas inmediatas rechazó el runnable: " 
Connect your IDE to all the code out there  Get Codota for Java