Skip to content

Commit

Permalink
Merge pull request #1419 from mattrjacobs/never-let-maximum-size-and-…
Browse files Browse the repository at this point in the history
…core-size-diverge-unless-user-opts-in

When user has not opted in to letting core/maximum threadpools diverge, ensure dynamic updates to coreSize apply to both
  • Loading branch information
mattrjacobs authored Nov 10, 2016
2 parents b7b955b + ef5047d commit 1f6e9d4
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,16 @@ private void touchConfig() {
boolean maxTooLow = false;

if (allowSizesToDiverge && dynamicMaximumSize < dynamicCoreSize) {
//if user sets maximum < core (or defaults get us there), we need to maintain invariant of core <= maximum
dynamicMaximumSize = dynamicCoreSize;
maxTooLow = true;
}

if (!allowSizesToDiverge) {
//if user has not opted in to allowing sizes to diverge, ensure maximum == core
dynamicMaximumSize = dynamicCoreSize;
}

// In JDK 6, setCorePoolSize and setMaximumPoolSize will execute a lock operation. Avoid them if the pool size is not changed.
if (threadPool.getCorePoolSize() != dynamicCoreSize || (allowSizesToDiverge && threadPool.getMaximumPoolSize() != dynamicMaximumSize)) {
if (maxTooLow) {
Expand Down

0 comments on commit 1f6e9d4

Please sign in to comment.