17 |
|
import java.util.concurrent.CancellationException; |
18 |
|
import java.util.concurrent.CountDownLatch; |
19 |
|
import java.util.concurrent.ExecutionException; |
20 |
– |
import java.util.concurrent.Executors; |
20 |
|
import java.util.concurrent.ExecutorService; |
21 |
|
import java.util.concurrent.Future; |
22 |
|
import java.util.concurrent.FutureTask; |
1724 |
|
LONG_DELAY_MS, MILLISECONDS, |
1725 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1726 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1727 |
+ |
long startTime = System.nanoTime(); |
1728 |
|
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
1729 |
|
l.add(new NPETask()); |
1730 |
|
try { |
1731 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1731 |
> |
e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
1732 |
|
shouldThrow(); |
1733 |
|
} catch (ExecutionException success) { |
1734 |
|
assertTrue(success.getCause() instanceof NullPointerException); |
1735 |
|
} |
1736 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1737 |
|
} |
1738 |
|
} |
1739 |
|
|
1746 |
|
LONG_DELAY_MS, MILLISECONDS, |
1747 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1748 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1749 |
+ |
long startTime = System.nanoTime(); |
1750 |
|
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
1751 |
|
l.add(new StringTask()); |
1752 |
|
l.add(new StringTask()); |
1753 |
< |
String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1753 |
> |
String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
1754 |
|
assertSame(TEST_STRING, result); |
1755 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1756 |
|
} |
1757 |
|
} |
1758 |
|
|