# How do we get the first completed Async Activity?

**URL:** <https://community.temporal.io/t/how-do-we-get-the-first-completed-async-activity/2318>\
**Category:** Community Support\
**Tags:** async\
**Created:** [June 7, 2021, 7:46pm UTC](https://community.temporal.io/t/how-do-we-get-the-first-completed-async-activity/2318 "2021-06-07T19:46:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Sun](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/steven_sun/32/29_2.png) [@Steven\_Sun](https://community.temporal.io/u/Steven_Sun)\
**Post date:** [June 7, 2021, 7:46pm UTC](https://community.temporal.io/t/how-do-we-get-the-first-completed-async-activity/2318/1 "2021-06-07T19:46:41Z")

</div>

I couldn’t find an example online but it seems like when we call multiple async activities there is no elegant way of knowing which one has completed first.In a normal case I would use Java CompletionService which gives the first Future that completed. But in the case of Temporal I only see running a simply for loop and doing a synchronous wait on the `promise.get()`

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [June 7, 2021, 10:21pm UTC](https://community.temporal.io/t/how-do-we-get-the-first-completed-async-activity/2318/2 "2021-06-07T22:21:19Z")

</div>

You can use

`Promise.anyOf(promiseList);`

where promiseList is a `List<Promise>` which can contain your Async.function calls, for example:

`promiseList.add(Async.function(myActivities::doSomething, inputA, inputB));`  
…

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Steven\_Sun](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/steven_sun/32/29_2.png) [@Steven\_Sun](https://community.temporal.io/u/Steven_Sun)\
**Post date:** [June 7, 2021, 10:31pm UTC](https://community.temporal.io/t/how-do-we-get-the-first-completed-async-activity/2318/3 "2021-06-07T22:31:14Z")

</div>

this returns the first completed ones right？

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [June 7, 2021, 10:47pm UTC](https://community.temporal.io/t/how-do-we-get-the-first-completed-async-activity/2318/4 "2021-06-07T22:47:20Z")

</div>

Yes - [Promise - temporal-sdk 1.0.9 javadoc](https://www.javadoc.io/doc/io.temporal/temporal-sdk/latest/io/temporal/workflow/Promise.html)
