Created
April 23, 2013 20:25
-
-
Save tadas-subonis/5447089 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void test(String[] args) throws Throwable { | |
ThreadPoolExecutor tpe = prepareTestThreadPool(threadCount, timeoutMillis); | |
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); | |
while (countExecutorThreads() > 0 && | |
millisElapsedSince(t0) < 10 * 1000); | |
equal(countExecutorThreads(), 0); | |
tpe.shutdown(); | |
check(tpe.allowsCoreThreadTimeOut()); | |
check(tpe.awaitTermination(10, TimeUnit.SECONDS)); | |
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); | |
if (failed > 0) throw new Exception("Some tests failed"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment