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