8166057: [testbug] CoreThreadTimeOut still uses hardcoded timeout
Reviewed-by: martin, chegar, shade
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java Fri Sep 23 13:14:14 2016 -0700
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java Fri Sep 23 13:18:22 2016 -0700
@@ -83,15 +83,18 @@
tpe.allowCoreThreadTimeOut(true);
check(tpe.allowsCoreThreadTimeOut());
equal(countExecutorThreads(), 0);
- long t0 = System.nanoTime();
- for (int i = 0; i < threadCount; i++)
- tpe.submit(new Runnable() { public void run() {}});
- int count = countExecutorThreads();
- if (millisElapsedSince(t0) < timeoutMillis)
- equal(count, threadCount);
+ long startTime = System.nanoTime();
+ for (int i = 0; i < threadCount; i++) {
+ tpe.submit(() -> {});
+ int count = countExecutorThreads();
+ if (millisElapsedSince(startTime) < timeoutMillis)
+ equal(count, i + 1);
+ }
while (countExecutorThreads() > 0 &&
- millisElapsedSince(t0) < 10 * 1000);
+ millisElapsedSince(startTime) < LONG_DELAY_MS)
+ Thread.yield();
equal(countExecutorThreads(), 0);
+ check(millisElapsedSince(startTime) >= timeoutMillis);
tpe.shutdown();
check(tpe.allowsCoreThreadTimeOut());
check(tpe.awaitTermination(LONG_DELAY_MS, MILLISECONDS));