@@ -1256,11 +1256,15 @@ public ThreadPoolExecutor(int corePoolSize,
1256
1256
BlockingQueue <Runnable > workQueue ,
1257
1257
ThreadFactory threadFactory ,
1258
1258
RejectedExecutionHandler handler ) {
1259
- if (corePoolSize < 0 ||
1260
- maximumPoolSize <= 0 ||
1261
- maximumPoolSize < corePoolSize ||
1262
- keepAliveTime < 0 )
1263
- throw new IllegalArgumentException ();
1259
+ if (corePoolSize < 0 ) {
1260
+ throw new IllegalArgumentException ("corePoolSize < 0" );
1261
+ } else if (maximumPoolSize <= 0 ) {
1262
+ throw new IllegalArgumentException ("maximumPoolSize <= 0" );
1263
+ } else if (maximumPoolSize < corePoolSize ) {
1264
+ throw new IllegalArgumentException ("maximumPoolSize < corePoolSize" );
1265
+ } else if (keepAliveTime < 0 ) {
1266
+ throw new IllegalArgumentException ("keepAliveTime < 0" );
1267
+ }
1264
1268
if (workQueue == null || threadFactory == null || handler == null )
1265
1269
throw new NullPointerException ();
1266
1270
this .corePoolSize = corePoolSize ;
@@ -1503,8 +1507,11 @@ public RejectedExecutionHandler getRejectedExecutionHandler() {
1503
1507
* @see #getCorePoolSize
1504
1508
*/
1505
1509
public void setCorePoolSize (int corePoolSize ) {
1506
- if (corePoolSize < 0 || maximumPoolSize < corePoolSize )
1507
- throw new IllegalArgumentException ();
1510
+ if (corePoolSize < 0 ) {
1511
+ throw new IllegalArgumentException ("corePoolSize < 0" );
1512
+ } else if (corePoolSize > maximumPoolSize ) {
1513
+ throw new IllegalArgumentException ("corePoolSize > maximumPoolSize" );
1514
+ }
1508
1515
int delta = corePoolSize - this .corePoolSize ;
1509
1516
this .corePoolSize = corePoolSize ;
1510
1517
if (workerCountOf (ctl .get ()) > corePoolSize )
@@ -1628,8 +1635,11 @@ public void allowCoreThreadTimeOut(boolean value) {
1628
1635
* @see #getMaximumPoolSize
1629
1636
*/
1630
1637
public void setMaximumPoolSize (int maximumPoolSize ) {
1631
- if (maximumPoolSize <= 0 || maximumPoolSize < corePoolSize )
1632
- throw new IllegalArgumentException ();
1638
+ if (maximumPoolSize <= 0 ) {
1639
+ throw new IllegalArgumentException ("maximumPoolSize <= 0" );
1640
+ } else if (maximumPoolSize < corePoolSize ) {
1641
+ throw new IllegalArgumentException ("maximumPoolSize < corePoolSize" );
1642
+ }
1633
1643
this .maximumPoolSize = maximumPoolSize ;
1634
1644
if (workerCountOf (ctl .get ()) > maximumPoolSize )
1635
1645
interruptIdleWorkers ();
@@ -1663,7 +1673,7 @@ public int getMaximumPoolSize() {
1663
1673
*/
1664
1674
public void setKeepAliveTime (long time , TimeUnit unit ) {
1665
1675
if (time < 0 )
1666
- throw new IllegalArgumentException ();
1676
+ throw new IllegalArgumentException ("time < 0" );
1667
1677
if (time == 0 && allowsCoreThreadTimeOut ())
1668
1678
throw new IllegalArgumentException ("Core threads must have nonzero keep alive times" );
1669
1679
long keepAliveTime = unit .toNanos (time );
0 commit comments