28 |
|
import java.util.concurrent.SynchronousQueue; |
29 |
|
import java.util.concurrent.ThreadFactory; |
30 |
|
import java.util.concurrent.ThreadPoolExecutor; |
31 |
– |
import java.util.concurrent.TimeUnit; |
31 |
|
import java.util.concurrent.atomic.AtomicInteger; |
32 |
|
|
33 |
|
import junit.framework.Test; |
1726 |
|
LONG_DELAY_MS, MILLISECONDS, |
1727 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1728 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1729 |
+ |
long startTime = System.nanoTime(); |
1730 |
|
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
1731 |
|
l.add(new NPETask()); |
1732 |
|
try { |
1733 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1733 |
> |
e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
1734 |
|
shouldThrow(); |
1735 |
|
} catch (ExecutionException success) { |
1736 |
|
assertTrue(success.getCause() instanceof NullPointerException); |
1737 |
|
} |
1738 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1739 |
|
} |
1740 |
|
} |
1741 |
|
|
1748 |
|
LONG_DELAY_MS, MILLISECONDS, |
1749 |
|
new ArrayBlockingQueue<Runnable>(10)); |
1750 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1751 |
+ |
long startTime = System.nanoTime(); |
1752 |
|
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
1753 |
|
l.add(new StringTask()); |
1754 |
|
l.add(new StringTask()); |
1755 |
< |
String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1755 |
> |
String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
1756 |
|
assertSame(TEST_STRING, result); |
1757 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1758 |
|
} |
1759 |
|
} |
1760 |
|
|