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 |
|
} |
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(); |
549 |
|
ExecutorService e = new ForkJoinPool(1); |
550 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
551 |
|
try { |
552 |
< |
Future<String> unused = 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(); |