1331 |
|
} |
1332 |
|
|
1333 |
|
/** |
1334 |
+ |
* Configuration changes that allow core pool size greater than |
1335 |
+ |
* max pool size result in IllegalArgumentException. |
1336 |
+ |
*/ |
1337 |
+ |
public void testPoolSizeInvariants() { |
1338 |
+ |
ThreadPoolExecutor p = |
1339 |
+ |
new ThreadPoolExecutor(1, 1, |
1340 |
+ |
LONG_DELAY_MS, MILLISECONDS, |
1341 |
+ |
new ArrayBlockingQueue<Runnable>(10)); |
1342 |
+ |
for (int s = 1; s < 5; s++) { |
1343 |
+ |
p.setMaximumPoolSize(s); |
1344 |
+ |
p.setCorePoolSize(s); |
1345 |
+ |
try { |
1346 |
+ |
p.setMaximumPoolSize(s - 1); |
1347 |
+ |
shouldThrow(); |
1348 |
+ |
} catch (IllegalArgumentException success) {} |
1349 |
+ |
assertEquals(s, p.getCorePoolSize()); |
1350 |
+ |
assertEquals(s, p.getMaximumPoolSize()); |
1351 |
+ |
try { |
1352 |
+ |
p.setCorePoolSize(s + 1); |
1353 |
+ |
shouldThrow(); |
1354 |
+ |
} catch (IllegalArgumentException success) {} |
1355 |
+ |
assertEquals(s, p.getCorePoolSize()); |
1356 |
+ |
assertEquals(s, p.getMaximumPoolSize()); |
1357 |
+ |
} |
1358 |
+ |
joinPool(p); |
1359 |
+ |
} |
1360 |
+ |
|
1361 |
+ |
/** |
1362 |
|
* setKeepAliveTime throws IllegalArgumentException |
1363 |
|
* when given a negative value |
1364 |
|
*/ |