# Parallel and sequential tasks | EasyNet Docs Source: https://easynet.run/docs/aal/reference/actions # Parallel and sequential tasks A report may calculate several metrics at once, or collect data before producing a conclusion. Choose the execution pattern based on dependencies between steps. ## Independent calculations To calculate two order totals, use parallel. Both branches read values that are already available: ``` agent Orders is Agent public ability run() -> List effects() totals = parallel 3 * 20 2 * 35 return totals ``` Save this as orders.aal and run it from the AAL repository: ``` cargo run --locked --bin aalc -- run orders.aal --agent Orders --ability run --args '{}' --state-dir /tmp/aal-orders --invocation orders-1 ``` The result is [60,70]. The first element always belongs to the first order, even if the second branch finishes first. Execution continues only after both branches finish. ## One step depends on another Calculate the total before deciding whether shipping is free: ``` agent Checkout is Agent public ability run(quantity: Int, price: Int) -> String effects() total = quantity * price shipping = if total >= 100 then 0 else 10 return "Total: {total + shipping}" ``` With {"quantity":3,"price":40}, the result is "Total: 120". Changing quantity to 2 returns "Total: 90". Shipping reads total, so these steps should not be independent parallel branches. ## Save progress between steps Use a [persistent workflow](https://easynet.run/docs/aal/workflows) for tasks with multiple stages that need to preserve progress. Write each stage as a state and use -> for transitions. Resume with the original invocation ID and state directory. Local assignments hold intermediate values for the current call. Memory holds data needed by later calls. Workflows organize staged execution and recovery. Choose based on what you need to preserve. ## Waiting, cancellation and dynamic instances The current language does not provide native async/await Action handles or keyed Agent instance factories for this tutorial. parallel does not return handles for cancelling individual branches. Check your version's supported features before using proposed syntax. To generate calculation functions with different rules, use [closure factories](https://easynet.run/docs/aal/reference/closures). To organize Agents across packages, follow the [account example](https://easynet.run/docs/aal/reference/composition).