/** {@inheritDoc} */ public void setMaxThreads(final int maxThreads) { final Lock lock = this.lock; lock.lock(); try { final int oldLimit = this.maxThreads; if (maxThreads < coreThreads) { // don't let the max thread limit be less than the core thread limit. // the called method will signal as needed setCoreThreads(maxThreads); } else if (oldLimit < maxThreads) { // we're growing the number of extra threads // therefore signal anyone waiting to add tasks; there might be more threads to add removeCondition.signalAll(); } else if (oldLimit > maxThreads) { // we're shrinking the number of extra threads // therefore signal anyone waiting to remove tasks so the pool can shrink properly enqueueCondition.signalAll(); } else { // we aren't changing anything... return; } this.maxThreads = maxThreads; } finally { lock.unlock(); } }
void setCoreThreads(int coreThreads) { executor.setCoreThreads(coreThreads); }
/** {@inheritDoc} */ public void setMaxThreads(final int maxThreads) { final Lock lock = this.lock; lock.lock(); try { final int oldLimit = this.maxThreads; if (maxThreads < coreThreads) { // don't let the max thread limit be less than the core thread limit. // the called method will signal as needed setCoreThreads(maxThreads); } else if (oldLimit < maxThreads) { // we're growing the number of extra threads // therefore signal anyone waiting to add tasks; there might be more threads to add removeCondition.signalAll(); } else if (oldLimit > maxThreads) { // we're shrinking the number of extra threads // therefore signal anyone waiting to remove tasks so the pool can shrink properly enqueueCondition.signalAll(); } else { // we aren't changing anything... return; } this.maxThreads = maxThreads; } finally { lock.unlock(); } }
/** {@inheritDoc} */ public void setMaxThreads(final int maxThreads) { final Lock lock = this.lock; lock.lock(); try { final int oldLimit = this.maxThreads; if (maxThreads < coreThreads) { // don't let the max thread limit be less than the core thread limit. // the called method will signal as needed setCoreThreads(maxThreads); } else if (oldLimit < maxThreads) { // we're growing the number of extra threads // therefore signal anyone waiting to add tasks; there might be more threads to add removeCondition.signalAll(); } else if (oldLimit > maxThreads) { // we're shrinking the number of extra threads // therefore signal anyone waiting to remove tasks so the pool can shrink properly enqueueCondition.signalAll(); } else { // we aren't changing anything... return; } this.maxThreads = maxThreads; } finally { lock.unlock(); } }