> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/async/asyncall.md).

# AsyncAll

This BIF accepts an array of futures/closures/lambdas and executes them all in parallel.

It returns a BoxFuture that will contain an array of results once all futures are completed successfully.

This means that the futures will be executed in parallel and the results will be returned in the order that they were passed in. This also means that this operation is non-blocking and will return immediately until you call get() on the future.

Each future can be a BoxFuture or a CompletableFuture or a BoxLang Function that will be treated as a future.

```
 results = all( [f1, f2, f3] ).get()
 all( [f1, f2, f3] ).then( (values) => logResults( values ) );
 
```

## Method Signature

```
AsyncAll(futures=[array], executor=[any])
```

### Arguments

| Argument   | Type    | Required | Description                                                                                                                                                                                                                  | Default |
| ---------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `futures`  | `array` | `true`   | An array of BoxFuture objects to process in parallel                                                                                                                                                                         |         |
| `executor` | `any`   | `false`  | <p>The executor to use for the BoxFuture object. By default, the BoxFuture object will use the<br>default executor (ForkJoinPool.commonPool()). This can be the name of a named executor or a<br>custom executor record.</p> |         |

## Examples

### Wait for all async operations to complete

Accepts an array of futures/closures/lambdas and executes them all in parallel.

```java
f1 = asyncRun( () => sleep( 100 ) && return "one" );
f2 = asyncRun( () => sleep( 100 ) && return "two" );
f3 = asyncRun( () => sleep( 100 ) && return "three" );
results = all( [ f1, f2, f3 ] ).get();
writeOutput( results.len() );

```

Result: 3

### Results are returned in the order they were passed

```java
slow = asyncRun( () => sleep( 200 ) && return "slow" );
fast = asyncRun( () => sleep( 50 ) && return "fast" );
results = all( [ slow, fast ] ).get();
writeOutput( results[ 1 ] );

```

Result: slow

### Using closures directly without pre-creating futures

```java
results = all( [
    () => 10 * 2,
    () => 20 * 2,
    () => 30 * 2
] ).get();
writeOutput( results.toString() );

```

Result: \[20, 40, 60]

## Related

* [AsyncAllApply](/boxlang-language/reference/built-in-functions/async/asyncallapply.md)
* [AsyncAny](/boxlang-language/reference/built-in-functions/async/asyncany.md)
* [AsyncRun](/boxlang-language/reference/built-in-functions/async/asyncrun.md)
* [ExecutorDelete](/boxlang-language/reference/built-in-functions/async/executordelete.md)
* [ExecutorGet](/boxlang-language/reference/built-in-functions/async/executorget.md)
* [ExecutorHas](/boxlang-language/reference/built-in-functions/async/executorhas.md)
* [ExecutorList](/boxlang-language/reference/built-in-functions/async/executorlist.md)
* [ExecutorNew](/boxlang-language/reference/built-in-functions/async/executornew.md)
* [ExecutorShutdown](/boxlang-language/reference/built-in-functions/async/executorshutdown.md)
* [ExecutorStatus](/boxlang-language/reference/built-in-functions/async/executorstatus.md)
* [FutureNew](/boxlang-language/reference/built-in-functions/async/futurenew.md)
* [IsInThread](/boxlang-language/reference/built-in-functions/async/isinthread.md)
* [isThreadAlive](/boxlang-language/reference/built-in-functions/async/isthreadalive.md)
* [IsThreadInterrupted](/boxlang-language/reference/built-in-functions/async/isthreadinterrupted.md)
* [RunAsync](/boxlang-language/reference/built-in-functions/async/runasync.md)
* [ThreadCurrent](/boxlang-language/reference/built-in-functions/async/threadcurrent.md)
* [ThreadInterrupt](/boxlang-language/reference/built-in-functions/async/threadinterrupt.md)
* [ThreadJoin](/boxlang-language/reference/built-in-functions/async/threadjoin.md)
* [ThreadNew](/boxlang-language/reference/built-in-functions/async/threadnew.md)
* [ThreadTerminate](/boxlang-language/reference/built-in-functions/async/threadterminate.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/async/asyncall.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
