217 |
|
taskStarted.countDown(); |
218 |
|
assertEquals(1, p.getPoolSize()); |
219 |
|
assertEquals(1, p.getActiveThreadCount()); |
220 |
< |
done.await(); |
220 |
> |
await(done); |
221 |
|
}}; |
222 |
|
Future<?> future = p.submit(task); |
223 |
|
await(taskStarted); |
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)); |
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()); |
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); |
720 |
|
public void testInvokeAll3() throws InterruptedException { |
721 |
|
ExecutorService e = new ForkJoinPool(1); |
722 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
723 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
723 |
> |
List<Callable<String>> l = new ArrayList<>(); |
724 |
|
l.add(new StringTask()); |
725 |
|
l.add(null); |
726 |
|
try { |
737 |
|
public void testInvokeAll4() throws Throwable { |
738 |
|
ExecutorService e = new ForkJoinPool(1); |
739 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
740 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
740 |
> |
List<Callable<String>> l = new ArrayList<>(); |
741 |
|
l.add(new NPETask()); |
742 |
|
List<Future<String>> futures = e.invokeAll(l); |
743 |
|
assertEquals(1, futures.size()); |
756 |
|
public void testInvokeAll5() throws Throwable { |
757 |
|
ExecutorService e = new ForkJoinPool(1); |
758 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
759 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
759 |
> |
List<Callable<String>> l = new ArrayList<>(); |
760 |
|
l.add(new StringTask()); |
761 |
|
l.add(new StringTask()); |
762 |
|
List<Future<String>> futures = e.invokeAll(l); |
773 |
|
ExecutorService e = new ForkJoinPool(1); |
774 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
775 |
|
try { |
776 |
< |
e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS); |
776 |
> |
e.invokeAny(null, randomTimeout(), randomTimeUnit()); |
777 |
|
shouldThrow(); |
778 |
|
} catch (NullPointerException success) {} |
779 |
|
} |
785 |
|
public void testTimedInvokeAnyNullTimeUnit() throws Throwable { |
786 |
|
ExecutorService e = new ForkJoinPool(1); |
787 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
788 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
788 |
> |
List<Callable<String>> l = new ArrayList<>(); |
789 |
|
l.add(new StringTask()); |
790 |
|
try { |
791 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, null); |
791 |
> |
e.invokeAny(l, randomTimeout(), null); |
792 |
|
shouldThrow(); |
793 |
|
} catch (NullPointerException success) {} |
794 |
|
} |
802 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
803 |
|
try { |
804 |
|
e.invokeAny(new ArrayList<Callable<String>>(), |
805 |
< |
MEDIUM_DELAY_MS, MILLISECONDS); |
805 |
> |
randomTimeout(), randomTimeUnit()); |
806 |
|
shouldThrow(); |
807 |
|
} catch (IllegalArgumentException success) {} |
808 |
|
} |
815 |
|
CountDownLatch latch = new CountDownLatch(1); |
816 |
|
ExecutorService e = new ForkJoinPool(1); |
817 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
818 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
818 |
> |
List<Callable<String>> l = new ArrayList<>(); |
819 |
|
l.add(latchAwaitingStringTask(latch)); |
820 |
|
l.add(null); |
821 |
|
try { |
833 |
|
ExecutorService e = new ForkJoinPool(1); |
834 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
835 |
|
long startTime = System.nanoTime(); |
836 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
836 |
> |
List<Callable<String>> l = new ArrayList<>(); |
837 |
|
l.add(new NPETask()); |
838 |
|
try { |
839 |
|
e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
852 |
|
ExecutorService e = new ForkJoinPool(1); |
853 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
854 |
|
long startTime = System.nanoTime(); |
855 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
855 |
> |
List<Callable<String>> l = new ArrayList<>(); |
856 |
|
l.add(new StringTask()); |
857 |
|
l.add(new StringTask()); |
858 |
|
String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
880 |
|
public void testTimedInvokeAllNullTimeUnit() throws Throwable { |
881 |
|
ExecutorService e = new ForkJoinPool(1); |
882 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
883 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
883 |
> |
List<Callable<String>> l = new ArrayList<>(); |
884 |
|
l.add(new StringTask()); |
885 |
|
try { |
886 |
|
e.invokeAll(l, MEDIUM_DELAY_MS, null); |
908 |
|
public void testTimedInvokeAll3() throws InterruptedException { |
909 |
|
ExecutorService e = new ForkJoinPool(1); |
910 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
911 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
911 |
> |
List<Callable<String>> l = new ArrayList<>(); |
912 |
|
l.add(new StringTask()); |
913 |
|
l.add(null); |
914 |
|
try { |
924 |
|
public void testTimedInvokeAll4() throws Throwable { |
925 |
|
ExecutorService e = new ForkJoinPool(1); |
926 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
927 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
927 |
> |
List<Callable<String>> l = new ArrayList<>(); |
928 |
|
l.add(new NPETask()); |
929 |
|
List<Future<String>> futures |
930 |
|
= e.invokeAll(l, LONG_DELAY_MS, MILLISECONDS); |
944 |
|
public void testTimedInvokeAll5() throws Throwable { |
945 |
|
ForkJoinPool e = new ForkJoinPool(1); |
946 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
947 |
< |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
947 |
> |
List<Callable<String>> l = new ArrayList<>(); |
948 |
|
l.add(new StringTask()); |
949 |
|
l.add(new StringTask()); |
950 |
|
List<Future<String>> futures |