src/share/classes/java/util/concurrent/ThreadPoolExecutor.java
Print this page
rev 9918 : 7153400: ThreadPoolExecutor's setCorePoolSize method allows corePoolSize > maxPoolSize
Reviewed-by: chegar, dl
Contributed-by: pavel.rappo@oracle.com
@@ -1530,14 +1530,16 @@
* they next become idle. If larger, new threads will, if needed,
* be started to execute any queued tasks.
*
* @param corePoolSize the new core size
* @throws IllegalArgumentException if {@code corePoolSize < 0}
+ * or {@code corePoolSize} is greater than the {@linkplain
+ * #getMaximumPoolSize() maximum pool size}
* @see #getCorePoolSize
*/
public void setCorePoolSize(int corePoolSize) {
- if (corePoolSize < 0)
+ if (corePoolSize < 0 || maximumPoolSize < corePoolSize)
throw new IllegalArgumentException();
int delta = corePoolSize - this.corePoolSize;
this.corePoolSize = corePoolSize;
if (workerCountOf(ctl.get()) > corePoolSize)
interruptIdleWorkers();