1 |
|
/* |
2 |
< |
* Written by members of JCP JSR-166 Expert Group and released to the |
3 |
< |
* public domain. Use, modify, and redistribute this code in any way |
4 |
< |
* without acknowledgement. Other contributors include Andrew Wright, |
5 |
< |
* Jeffrey Hayes, Pat Fischer, Mike Judd. |
2 |
> |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
> |
* Expert Group and released to the public domain, as explained at |
4 |
> |
* http://creativecommons.org/licenses/publicdomain |
5 |
> |
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
> |
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
|
import java.util.concurrent.*; |
1482 |
|
try { |
1483 |
|
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
1484 |
|
l.add(new StringTask()); |
1485 |
< |
l.add(Executors.callable(new MediumInterruptedRunnable(), TEST_STRING)); |
1485 |
> |
l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING)); |
1486 |
> |
l.add(new StringTask()); |
1487 |
|
List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
1488 |
< |
assertEquals(2, result.size()); |
1488 |
> |
assertEquals(3, result.size()); |
1489 |
|
Iterator<Future<String>> it = result.iterator(); |
1490 |
|
Future<String> f1 = it.next(); |
1491 |
|
Future<String> f2 = it.next(); |
1492 |
+ |
Future<String> f3 = it.next(); |
1493 |
|
assertTrue(f1.isDone()); |
1491 |
– |
assertFalse(f1.isCancelled()); |
1494 |
|
assertTrue(f2.isDone()); |
1495 |
+ |
assertTrue(f3.isDone()); |
1496 |
+ |
assertFalse(f1.isCancelled()); |
1497 |
|
assertTrue(f2.isCancelled()); |
1498 |
|
} catch(Exception ex) { |
1499 |
|
unexpectedException(); |