286 |
|
// Java8+ test classes |
287 |
|
if (atLeastJava8()) { |
288 |
|
String[] java8TestClassNames = { |
289 |
+ |
"LongAdderTest", |
290 |
+ |
"LongAccumulatorTest", |
291 |
+ |
"DoubleAdderTest", |
292 |
+ |
"DoubleAccumulatorTest", |
293 |
+ |
"CompletableFutureTest", |
294 |
+ |
"ForkJoinPool8Test", |
295 |
|
"StampedLockTest", |
296 |
|
}; |
297 |
|
addNamedTestClasses(suite, java8TestClassNames); |
389 |
|
|
390 |
|
if (Thread.interrupted()) |
391 |
|
throw new AssertionFailedError("interrupt status set in main thread"); |
392 |
+ |
|
393 |
+ |
checkForkJoinPoolThreadLeaks(); |
394 |
+ |
} |
395 |
+ |
|
396 |
+ |
/** |
397 |
+ |
* Find missing try { ... } finally { joinPool(e); } |
398 |
+ |
*/ |
399 |
+ |
void checkForkJoinPoolThreadLeaks() throws InterruptedException { |
400 |
+ |
Thread[] survivors = new Thread[5]; |
401 |
+ |
int count = Thread.enumerate(survivors); |
402 |
+ |
for (int i = 0; i < count; i++) { |
403 |
+ |
Thread thread = survivors[i]; |
404 |
+ |
String name = thread.getName(); |
405 |
+ |
if (name.startsWith("ForkJoinPool-")) { |
406 |
+ |
// give thread some time to terminate |
407 |
+ |
thread.join(LONG_DELAY_MS); |
408 |
+ |
if (!thread.isAlive()) continue; |
409 |
+ |
thread.stop(); |
410 |
+ |
throw new AssertionFailedError |
411 |
+ |
(String.format("Found leaked ForkJoinPool thread test=%s thread=%s%n", |
412 |
+ |
toString(), name)); |
413 |
+ |
} |
414 |
+ |
} |
415 |
|
} |
416 |
|
|
417 |
|
/** |