---
title: "Speed Things Up with Parallel Async Actions"
url: "https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/speed-things-up-with-parallel-async-actions.md"
canonical: "https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/speed-things-up-with-parallel-async-actions/"
tags: []
author: "Roy Osherove"
description: "Lesson 13 of 18 in Automating All the Things with FinalBuilder (Flow Control & Error Handling), 3:30. Free video by Roy Osherove."
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Speed Things Up with Parallel Async Actions

1. [Courses](https://courses.osherove.com/#courses)
2. [Automating All the Things with FinalBuilder](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/)
3. Flow Control & Error Handling

Lesson 13 of 18

Duration: 3:30 [Watch on YouTube](https://www.youtube.com/watch?v=k0Xgvvo94QI)

## In this lesson

Roy Osherove downloads several pages at the same time by wrapping the download actions in an async action group, which runs its child actions in multiple threads, with a maximum number of concurrent threads and an optional delay between thread starts. The group is also a sync point, as the action after it starts only when all of its actions finish, and he warns against async action groups for actions that change the same IO or write to the same variable, because of race conditions.

## Transcript

497 words

[\[00:03\]](https://www.youtube.com/watch?v=k0Xgvvo94QI&t=3s) Let's talk about a very powerful feature in FinalBuilder which allows speeding up multiple actions that take different amounts of time. And this is called async action groups. Let's say we have multiple pages we want to download at the same time, right? Let's fix the Google thing here so that it's actually working and let's download a few other sites. For example let's say red.com and

[\[00:48\]](https://www.youtube.com/watch?v=k0Xgvvo94QI&t=48s) Now I could for example just to show how things work I could just rightclick here and say run selected actions and children just to see that everything is working one at a time. Now if I wanted to and if these things are not IO bound or not changing the same file etc. If we let them run async and if we have let's say a CPU with multiple cores or multiple CPUs we could run things in multiple threads. So one way to do it if we look for async here

[\[01:20\]](https://www.youtube.com/watch?v=k0Xgvvo94QI&t=80s) We'll see an async action group or another way is to say select all these actions right click refactor wrap actions with async action group. Then we'll just move the action group left so it's not under the original group and remove the original group. Now if I try to run all these actions together, first of all, let's see what are the properties of the action group. Run all of the child actions asynchronously.

[\[01:53\]](https://www.youtube.com/watch?v=k0Xgvvo94QI&t=113s) I can set the maximum concurrent threads. If I have two CPU cores, it will be two. I can even set thread start delay. So if the threads start together, maybe it could cause an an error. But I can make it even start each thread after each after 1 second. For now, let's just start all of them at the same time or it will run two at the same time. I'm going to right click and say run selected actions and children. And what you'll see is that two of them are running at the same time every time.

[\[02:26\]](https://www.youtube.com/watch?v=k0Xgvvo94QI&t=146s) And the nice thing about action groups, async action groups, is that the action group is also a sync point. that is that the action after it it's sibling action not a child action will only start when the async action group all of them finish. So that's just simplified for us. If I try to run everything now should be able to see multiple threads running and only executing later.

[\[02:57\]](https://www.youtube.com/watch?v=k0Xgvvo94QI&t=177s) And now we actually have an error. Sorry that's not an error. We're just exporting the logs. So, no errors happened. So, that's an example of async action groups, how how they can help speed things up. But beware, don't use async action groups on anything that changes the same IO because it might cause problems or if you're writing to the same variable in multiple actions, of course, could cause the same problem. Same idea of race conditions and all that stuff. So, that's something to be aware of.

[Previous lesson Local Error Handling: Try-Catch-Finally Blocks](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/local-error-handling-try-catch-finally-blocks/) [Next lesson Invoking Other FinalBuilder Projects](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/invoking-other-finalbuilder-projects/)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
