()
| 50 | } |
| 51 | |
| 52 | @Test |
| 53 | @Timeout(5) |
| 54 | void testRace() throws Exception { |
| 55 | Future f1 = new Future(); |
| 56 | Future f2 = new Future(); |
| 57 | Future f3 = new Future(); |
| 58 | |
| 59 | Future winner = Future.race(f1, f2, f3); |
| 60 | assertFalse(winner.isDone()); |
| 61 | |
| 62 | f2.resolve("second wins"); |
| 63 | assertEquals("second wins", winner.getFuture().get(1, TimeUnit.SECONDS)); |
| 64 | } |
| 65 | |
| 66 | @Test |
| 67 | @Timeout(5) |