11 |
|
import java.security.PrivilegedExceptionAction; |
12 |
|
import java.util.ArrayList; |
13 |
|
import java.util.Collection; |
14 |
+ |
import java.util.Collections; |
15 |
|
import java.util.List; |
16 |
|
import java.util.concurrent.Callable; |
17 |
|
import java.util.concurrent.CountDownLatch; |
25 |
|
import java.util.concurrent.RecursiveTask; |
26 |
|
import java.util.concurrent.RejectedExecutionException; |
27 |
|
import java.util.concurrent.atomic.AtomicBoolean; |
28 |
+ |
import java.util.concurrent.atomic.AtomicInteger; |
29 |
|
import java.util.concurrent.locks.ReentrantLock; |
30 |
|
|
29 |
– |
import junit.framework.AssertionFailedError; |
31 |
|
import junit.framework.Test; |
32 |
|
import junit.framework.TestSuite; |
33 |
|
|
58 |
|
|
59 |
|
// Some classes to test extension and factory methods |
60 |
|
|
60 |
– |
static class MyHandler implements Thread.UncaughtExceptionHandler { |
61 |
– |
volatile int catches = 0; |
62 |
– |
public void uncaughtException(Thread t, Throwable e) { |
63 |
– |
++catches; |
64 |
– |
} |
65 |
– |
} |
66 |
– |
|
61 |
|
static class MyError extends Error {} |
62 |
|
|
63 |
|
// to test handlers |
68 |
|
|
69 |
|
static class FailingThreadFactory |
70 |
|
implements ForkJoinPool.ForkJoinWorkerThreadFactory { |
71 |
< |
volatile int calls = 0; |
71 |
> |
final AtomicInteger calls = new AtomicInteger(0); |
72 |
|
public ForkJoinWorkerThread newThread(ForkJoinPool p) { |
73 |
< |
if (++calls > 1) return null; |
73 |
> |
if (calls.incrementAndGet() > 1) return null; |
74 |
|
return new FailingFJWSubclass(p); |
75 |
|
} |
76 |
|
} |
109 |
|
return n; |
110 |
|
FibTask f1 = new FibTask(n - 1); |
111 |
|
f1.fork(); |
112 |
< |
return (new FibTask(n - 2)).compute() + f1.join(); |
112 |
> |
return new FibTask(n - 2).compute() + f1.join(); |
113 |
|
} |
114 |
|
} |
115 |
|
|
207 |
|
* getPoolSize returns number of started workers. |
208 |
|
*/ |
209 |
|
public void testGetPoolSize() { |
210 |
< |
ForkJoinPool p = new ForkJoinPool(1); |
210 |
> |
final CountDownLatch taskStarted = new CountDownLatch(1); |
211 |
> |
final CountDownLatch done = new CountDownLatch(1); |
212 |
> |
final ForkJoinPool p = new ForkJoinPool(1); |
213 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
214 |
|
assertEquals(0, p.getActiveThreadCount()); |
215 |
< |
Future<String> future = p.submit(new StringTask()); |
215 |
> |
final Runnable task = new CheckedRunnable() { |
216 |
> |
public void realRun() throws InterruptedException { |
217 |
> |
taskStarted.countDown(); |
218 |
> |
assertEquals(1, p.getPoolSize()); |
219 |
> |
assertEquals(1, p.getActiveThreadCount()); |
220 |
> |
await(done); |
221 |
> |
}}; |
222 |
> |
Future<?> future = p.submit(task); |
223 |
> |
await(taskStarted); |
224 |
|
assertEquals(1, p.getPoolSize()); |
225 |
+ |
assertEquals(1, p.getActiveThreadCount()); |
226 |
+ |
done.countDown(); |
227 |
|
} |
228 |
+ |
assertEquals(0, p.getPoolSize()); |
229 |
+ |
assertEquals(0, p.getActiveThreadCount()); |
230 |
|
} |
231 |
|
|
232 |
|
/** |
240 |
|
assertFalse(p.awaitTermination(Long.MIN_VALUE, MILLISECONDS)); |
241 |
|
assertFalse(p.awaitTermination(-1L, NANOSECONDS)); |
242 |
|
assertFalse(p.awaitTermination(-1L, MILLISECONDS)); |
243 |
< |
assertFalse(p.awaitTermination(0L, NANOSECONDS)); |
244 |
< |
assertFalse(p.awaitTermination(0L, MILLISECONDS)); |
243 |
> |
assertFalse(p.awaitTermination(randomExpiredTimeout(), |
244 |
> |
randomTimeUnit())); |
245 |
|
long timeoutNanos = 999999L; |
246 |
|
long startTime = System.nanoTime(); |
247 |
|
assertFalse(p.awaitTermination(timeoutNanos, NANOSECONDS)); |
303 |
|
p.getFactory()); |
304 |
|
while (! p.isQuiescent()) { |
305 |
|
if (millisElapsedSince(startTime) > LONG_DELAY_MS) |
306 |
< |
throw new AssertionFailedError("timed out"); |
306 |
> |
throw new AssertionError("timed out"); |
307 |
|
assertFalse(p.getAsyncMode()); |
308 |
|
assertFalse(p.isShutdown()); |
309 |
|
assertFalse(p.isTerminating()); |
313 |
|
|
314 |
|
assertTrue(p.isQuiescent()); |
315 |
|
assertFalse(p.getAsyncMode()); |
308 |
– |
assertEquals(0, p.getActiveThreadCount()); |
316 |
|
assertEquals(0, p.getQueuedTaskCount()); |
317 |
|
assertEquals(0, p.getQueuedSubmissionCount()); |
318 |
|
assertFalse(p.hasQueuedSubmissions()); |
319 |
+ |
while (p.getActiveThreadCount() != 0 |
320 |
+ |
&& millisElapsedSince(startTime) < LONG_DELAY_MS) |
321 |
+ |
Thread.yield(); |
322 |
|
assertFalse(p.isShutdown()); |
323 |
|
assertFalse(p.isTerminating()); |
324 |
|
assertFalse(p.isTerminated()); |
325 |
|
assertTrue(f.isDone()); |
326 |
|
assertEquals(6765, (int) f.get()); |
327 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
328 |
|
} |
329 |
|
} |
330 |
|
|
348 |
|
p.shutdown(); |
349 |
|
assertTrue(p.isShutdown()); |
350 |
|
try { |
351 |
< |
ForkJoinTask<Integer> f = p.submit(new FibTask(8)); |
351 |
> |
ForkJoinTask<Integer> unused = p.submit(new FibTask(8)); |
352 |
|
shouldThrow(); |
353 |
|
} catch (RejectedExecutionException success) {} |
354 |
|
} |
377 |
|
final CountDownLatch done = new CountDownLatch(1); |
378 |
|
SubFJP p = new SubFJP(); |
379 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
380 |
< |
ForkJoinTask a = p.submit(awaiter(done)); |
381 |
< |
ForkJoinTask b = p.submit(awaiter(done)); |
382 |
< |
ForkJoinTask c = p.submit(awaiter(done)); |
383 |
< |
ForkJoinTask r = p.pollSubmission(); |
380 |
> |
ForkJoinTask<?> a = p.submit(awaiter(done)); |
381 |
> |
ForkJoinTask<?> b = p.submit(awaiter(done)); |
382 |
> |
ForkJoinTask<?> c = p.submit(awaiter(done)); |
383 |
> |
ForkJoinTask<?> r = p.pollSubmission(); |
384 |
|
assertTrue(r == a || r == b || r == c); |
385 |
|
assertFalse(r.isDone()); |
386 |
|
done.countDown(); |
394 |
|
final CountDownLatch done = new CountDownLatch(1); |
395 |
|
SubFJP p = new SubFJP(); |
396 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
397 |
< |
ForkJoinTask a = p.submit(awaiter(done)); |
398 |
< |
ForkJoinTask b = p.submit(awaiter(done)); |
399 |
< |
ForkJoinTask c = p.submit(awaiter(done)); |
400 |
< |
ArrayList<ForkJoinTask> al = new ArrayList(); |
397 |
> |
ForkJoinTask<?> a = p.submit(awaiter(done)); |
398 |
> |
ForkJoinTask<?> b = p.submit(awaiter(done)); |
399 |
> |
ForkJoinTask<?> c = p.submit(awaiter(done)); |
400 |
> |
ArrayList<ForkJoinTask<?>> al = new ArrayList<>(); |
401 |
|
p.drainTasksTo(al); |
402 |
|
assertTrue(al.size() > 0); |
403 |
< |
for (ForkJoinTask r : al) { |
403 |
> |
for (ForkJoinTask<?> r : al) { |
404 |
|
assertTrue(r == a || r == b || r == c); |
405 |
|
assertFalse(r.isDone()); |
406 |
|
} |
422 |
|
done.set(true); |
423 |
|
}}); |
424 |
|
assertNull(future.get()); |
425 |
< |
assertNull(future.get(0, MILLISECONDS)); |
425 |
> |
assertNull(future.get(randomExpiredTimeout(), randomTimeUnit())); |
426 |
|
assertTrue(done.get()); |
427 |
|
assertTrue(future.isDone()); |
428 |
|
assertFalse(future.isCancelled()); |
472 |
|
* A submitted privileged action runs to completion |
473 |
|
*/ |
474 |
|
public void testSubmitPrivilegedAction() throws Exception { |
475 |
< |
final Callable callable = Executors.callable(new PrivilegedAction() { |
475 |
> |
final Callable<Object> callable = Executors.callable(new PrivilegedAction<Object>() { |
476 |
|
public Object run() { return TEST_STRING; }}); |
477 |
|
Runnable r = new CheckedRunnable() { |
478 |
|
public void realRun() throws Exception { |
479 |
|
ExecutorService e = new ForkJoinPool(1); |
480 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
481 |
< |
Future future = e.submit(callable); |
481 |
> |
Future<Object> future = e.submit(callable); |
482 |
|
assertSame(TEST_STRING, future.get()); |
483 |
|
} |
484 |
|
}}; |
490 |
|
* A submitted privileged exception action runs to completion |
491 |
|
*/ |
492 |
|
public void testSubmitPrivilegedExceptionAction() throws Exception { |
493 |
< |
final Callable callable = |
494 |
< |
Executors.callable(new PrivilegedExceptionAction() { |
493 |
> |
final Callable<Object> callable = |
494 |
> |
Executors.callable(new PrivilegedExceptionAction<Object>() { |
495 |
|
public Object run() { return TEST_STRING; }}); |
496 |
|
Runnable r = new CheckedRunnable() { |
497 |
|
public void realRun() throws Exception { |
498 |
|
ExecutorService e = new ForkJoinPool(1); |
499 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
500 |
< |
Future future = e.submit(callable); |
500 |
> |
Future<Object> future = e.submit(callable); |
501 |
|
assertSame(TEST_STRING, future.get()); |
502 |
|
} |
503 |
|
}}; |
509 |
|
* A submitted failed privileged exception action reports exception |
510 |
|
*/ |
511 |
|
public void testSubmitFailedPrivilegedExceptionAction() throws Exception { |
512 |
< |
final Callable callable = |
513 |
< |
Executors.callable(new PrivilegedExceptionAction() { |
512 |
> |
final Callable<Object> callable = |
513 |
> |
Executors.callable(new PrivilegedExceptionAction<Object>() { |
514 |
|
public Object run() { throw new IndexOutOfBoundsException(); }}); |
515 |
|
Runnable r = new CheckedRunnable() { |
516 |
|
public void realRun() throws Exception { |
517 |
|
ExecutorService e = new ForkJoinPool(1); |
518 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
519 |
< |
Future future = e.submit(callable); |
519 |
> |
Future<Object> future = e.submit(callable); |
520 |
|
try { |
521 |
|
future.get(); |
522 |
|
shouldThrow(); |
536 |
|
ExecutorService e = new ForkJoinPool(1); |
537 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
538 |
|
try { |
539 |
< |
Future<?> future = e.submit((Runnable) null); |
539 |
> |
Future<?> unused = e.submit((Runnable) null); |
540 |
|
shouldThrow(); |
541 |
|
} catch (NullPointerException success) {} |
542 |
|
} |
549 |
|
ExecutorService e = new ForkJoinPool(1); |
550 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
551 |
|
try { |
552 |
< |
Future<String> future = e.submit((Callable) null); |
552 |
> |
Future<String> unused = e.submit((Callable<String>) null); |
553 |
|
shouldThrow(); |
554 |
|
} catch (NullPointerException success) {} |
555 |
|
} |
589 |
|
ForkJoinPool p = new ForkJoinPool(1); |
590 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
591 |
|
try { |
592 |
< |
p.submit(new Callable() { |
592 |
> |
p.submit(new Callable<Object>() { |
593 |
|
public Object call() { throw new ArithmeticException(); }}) |
594 |
|
.get(); |
595 |
|
shouldThrow(); |
631 |
|
public void testInvokeAny3() throws Throwable { |
632 |
|
ExecutorService e = new ForkJoinPool(1); |
633 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
634 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
634 |
> |
List<Callable<String>> l = new ArrayList<>(); |
635 |
|
l.add(null); |
636 |
|
try { |
637 |
|
e.invokeAny(l); |
647 |
|
CountDownLatch latch = new CountDownLatch(1); |
648 |
|
ExecutorService e = new ForkJoinPool(1); |
649 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
650 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
650 |
> |
List<Callable<String>> l = new ArrayList<>(); |
651 |
|
l.add(latchAwaitingStringTask(latch)); |
652 |
|
l.add(null); |
653 |
|
try { |
664 |
|
public void testInvokeAny5() throws Throwable { |
665 |
|
ExecutorService e = new ForkJoinPool(1); |
666 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
667 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
667 |
> |
List<Callable<String>> l = new ArrayList<>(); |
668 |
|
l.add(new NPETask()); |
669 |
|
try { |
670 |
|
e.invokeAny(l); |
681 |
|
public void testInvokeAny6() throws Throwable { |
682 |
|
ExecutorService e = new ForkJoinPool(1); |
683 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
684 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
684 |
> |
List<Callable<String>> l = new ArrayList<>(); |
685 |
|
l.add(new StringTask()); |
686 |
|
l.add(new StringTask()); |
687 |
|
String result = e.invokeAny(l); |
703 |
|
} |
704 |
|
|
705 |
|
/** |
706 |
< |
* invokeAll(empty collection) returns empty collection |
706 |
> |
* invokeAll(empty collection) returns empty list |
707 |
|
*/ |
708 |
|
public void testInvokeAll2() throws InterruptedException { |
709 |
|
ExecutorService e = new ForkJoinPool(1); |
710 |
+ |
final Collection<Callable<String>> emptyCollection |
711 |
+ |
= Collections.emptyList(); |
712 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
713 |
< |
List<Future<String>> r |
701 |
< |
= e.invokeAll(new ArrayList<Callable<String>>()); |
713 |
> |
List<Future<String>> r = e.invokeAll(emptyCollection); |
714 |
|
assertTrue(r.isEmpty()); |
715 |
|
} |
716 |
|
} |
721 |
|
public void testInvokeAll3() throws InterruptedException { |
722 |
|
ExecutorService e = new ForkJoinPool(1); |
723 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
724 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
724 |
> |
List<Callable<String>> l = new ArrayList<>(); |
725 |
|
l.add(new StringTask()); |
726 |
|
l.add(null); |
727 |
|
try { |
738 |
|
public void testInvokeAll4() throws Throwable { |
739 |
|
ExecutorService e = new ForkJoinPool(1); |
740 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
741 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
741 |
> |
List<Callable<String>> l = new ArrayList<>(); |
742 |
|
l.add(new NPETask()); |
743 |
|
List<Future<String>> futures = e.invokeAll(l); |
744 |
|
assertEquals(1, futures.size()); |
757 |
|
public void testInvokeAll5() throws Throwable { |
758 |
|
ExecutorService e = new ForkJoinPool(1); |
759 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
760 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
760 |
> |
List<Callable<String>> l = new ArrayList<>(); |
761 |
|
l.add(new StringTask()); |
762 |
|
l.add(new StringTask()); |
763 |
|
List<Future<String>> futures = e.invokeAll(l); |
774 |
|
ExecutorService e = new ForkJoinPool(1); |
775 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
776 |
|
try { |
777 |
< |
e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS); |
777 |
> |
e.invokeAny(null, randomTimeout(), randomTimeUnit()); |
778 |
|
shouldThrow(); |
779 |
|
} catch (NullPointerException success) {} |
780 |
|
} |
786 |
|
public void testTimedInvokeAnyNullTimeUnit() throws Throwable { |
787 |
|
ExecutorService e = new ForkJoinPool(1); |
788 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
789 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
789 |
> |
List<Callable<String>> l = new ArrayList<>(); |
790 |
|
l.add(new StringTask()); |
791 |
|
try { |
792 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, null); |
792 |
> |
e.invokeAny(l, randomTimeout(), null); |
793 |
|
shouldThrow(); |
794 |
|
} catch (NullPointerException success) {} |
795 |
|
} |
803 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
804 |
|
try { |
805 |
|
e.invokeAny(new ArrayList<Callable<String>>(), |
806 |
< |
MEDIUM_DELAY_MS, MILLISECONDS); |
806 |
> |
randomTimeout(), randomTimeUnit()); |
807 |
|
shouldThrow(); |
808 |
|
} catch (IllegalArgumentException success) {} |
809 |
|
} |
816 |
|
CountDownLatch latch = new CountDownLatch(1); |
817 |
|
ExecutorService e = new ForkJoinPool(1); |
818 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
819 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
819 |
> |
List<Callable<String>> l = new ArrayList<>(); |
820 |
|
l.add(latchAwaitingStringTask(latch)); |
821 |
|
l.add(null); |
822 |
|
try { |
823 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
823 |
> |
e.invokeAny(l, randomTimeout(), randomTimeUnit()); |
824 |
|
shouldThrow(); |
825 |
|
} catch (NullPointerException success) {} |
826 |
|
latch.countDown(); |
833 |
|
public void testTimedInvokeAny4() throws Throwable { |
834 |
|
ExecutorService e = new ForkJoinPool(1); |
835 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
836 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
836 |
> |
long startTime = System.nanoTime(); |
837 |
> |
List<Callable<String>> l = new ArrayList<>(); |
838 |
|
l.add(new NPETask()); |
839 |
|
try { |
840 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
840 |
> |
e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
841 |
|
shouldThrow(); |
842 |
|
} catch (ExecutionException success) { |
843 |
|
assertTrue(success.getCause() instanceof NullPointerException); |
844 |
|
} |
845 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
846 |
|
} |
847 |
|
} |
848 |
|
|
852 |
|
public void testTimedInvokeAny5() throws Throwable { |
853 |
|
ExecutorService e = new ForkJoinPool(1); |
854 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
855 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
855 |
> |
long startTime = System.nanoTime(); |
856 |
> |
List<Callable<String>> l = new ArrayList<>(); |
857 |
|
l.add(new StringTask()); |
858 |
|
l.add(new StringTask()); |
859 |
< |
String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
859 |
> |
String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
860 |
|
assertSame(TEST_STRING, result); |
861 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
862 |
|
} |
863 |
|
} |
864 |
|
|
869 |
|
ExecutorService e = new ForkJoinPool(1); |
870 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
871 |
|
try { |
872 |
< |
e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS); |
872 |
> |
e.invokeAll(null, randomTimeout(), randomTimeUnit()); |
873 |
|
shouldThrow(); |
874 |
|
} catch (NullPointerException success) {} |
875 |
|
} |
881 |
|
public void testTimedInvokeAllNullTimeUnit() throws Throwable { |
882 |
|
ExecutorService e = new ForkJoinPool(1); |
883 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
884 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
884 |
> |
List<Callable<String>> l = new ArrayList<>(); |
885 |
|
l.add(new StringTask()); |
886 |
|
try { |
887 |
< |
e.invokeAll(l, MEDIUM_DELAY_MS, null); |
887 |
> |
e.invokeAll(l, randomTimeout(), null); |
888 |
|
shouldThrow(); |
889 |
|
} catch (NullPointerException success) {} |
890 |
|
} |
891 |
|
} |
892 |
|
|
893 |
|
/** |
894 |
< |
* timed invokeAll(empty collection) returns empty collection |
894 |
> |
* timed invokeAll(empty collection) returns empty list |
895 |
|
*/ |
896 |
|
public void testTimedInvokeAll2() throws InterruptedException { |
897 |
|
ExecutorService e = new ForkJoinPool(1); |
898 |
+ |
final Collection<Callable<String>> emptyCollection |
899 |
+ |
= Collections.emptyList(); |
900 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
901 |
|
List<Future<String>> r |
902 |
< |
= e.invokeAll(new ArrayList<Callable<String>>(), |
903 |
< |
MEDIUM_DELAY_MS, MILLISECONDS); |
902 |
> |
= e.invokeAll(emptyCollection, |
903 |
> |
randomTimeout(), randomTimeUnit()); |
904 |
|
assertTrue(r.isEmpty()); |
905 |
|
} |
906 |
|
} |
911 |
|
public void testTimedInvokeAll3() throws InterruptedException { |
912 |
|
ExecutorService e = new ForkJoinPool(1); |
913 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
914 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
914 |
> |
List<Callable<String>> l = new ArrayList<>(); |
915 |
|
l.add(new StringTask()); |
916 |
|
l.add(null); |
917 |
|
try { |
918 |
< |
e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); |
918 |
> |
e.invokeAll(l, randomTimeout(), randomTimeUnit()); |
919 |
|
shouldThrow(); |
920 |
|
} catch (NullPointerException success) {} |
921 |
|
} |
927 |
|
public void testTimedInvokeAll4() throws Throwable { |
928 |
|
ExecutorService e = new ForkJoinPool(1); |
929 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
930 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
930 |
> |
List<Callable<String>> l = new ArrayList<>(); |
931 |
|
l.add(new NPETask()); |
932 |
|
List<Future<String>> futures |
933 |
|
= e.invokeAll(l, LONG_DELAY_MS, MILLISECONDS); |
947 |
|
public void testTimedInvokeAll5() throws Throwable { |
948 |
|
ForkJoinPool e = new ForkJoinPool(1); |
949 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
950 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
950 |
> |
List<Callable<String>> l = new ArrayList<>(); |
951 |
|
l.add(new StringTask()); |
952 |
|
l.add(new StringTask()); |
953 |
|
List<Future<String>> futures |