215 |
|
new ThreadPoolExecutor(2, 2, |
216 |
|
1000, MILLISECONDS, |
217 |
|
new ArrayBlockingQueue<Runnable>(10)); |
218 |
< |
assertEquals(1, p.getKeepAliveTime(TimeUnit.SECONDS)); |
218 |
> |
assertEquals(1, p.getKeepAliveTime(SECONDS)); |
219 |
|
joinPool(p); |
220 |
|
} |
221 |
|
|
990 |
|
public void testInterruptedSubmit() throws InterruptedException { |
991 |
|
final ThreadPoolExecutor p = |
992 |
|
new ThreadPoolExecutor(1, 1, |
993 |
< |
60, TimeUnit.SECONDS, |
993 |
> |
60, SECONDS, |
994 |
|
new ArrayBlockingQueue<Runnable>(10)); |
995 |
|
|
996 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
1264 |
|
*/ |
1265 |
|
public void testExecuteNull() { |
1266 |
|
ThreadPoolExecutor p = |
1267 |
< |
new ThreadPoolExecutor(1, 2, |
1268 |
< |
LONG_DELAY_MS, MILLISECONDS, |
1267 |
> |
new ThreadPoolExecutor(1, 2, 1L, SECONDS, |
1268 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1269 |
|
try { |
1270 |
|
p.execute(null); |
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 |
|
*/ |
2010 |
|
done.countDown(); |
2011 |
|
}}; |
2012 |
|
final ThreadPoolExecutor p = |
2013 |
< |
new ThreadPoolExecutor(1, 30, 60, TimeUnit.SECONDS, |
2013 |
> |
new ThreadPoolExecutor(1, 30, |
2014 |
> |
60, SECONDS, |
2015 |
|
new ArrayBlockingQueue(30)); |
2016 |
|
try { |
2017 |
|
for (int i = 0; i < nTasks; ++i) { |