Run Concurrent Threads
Component | Type | Description | |
---|---|---|---|
Run Concurrent Threads | ๐ action | Run Concurrent Threads in a workflow |
The Run Concurrent Threads component allows you to run parts of a workflow as multiple concurrent threads inside of a workflow session. A thread represents a run of a workflow or part of a workflow that can operate concurrently and independently of other threads inside of a workflow session or run. All components that follow after the Run Concurrent Threads component will be run as a thread, with one thread created for each value in the input list provided. For example, if you pass in a list of 10,000 values into a Run Concurrent Threads, it will run any further actions as 10,000 threads. Each thread runs concurrently, in parallel and independently of each other meaning they all execute at the same time:
What is a ๐งต thread?โ
When a workflow is run, that run is called a session. Inside of a session, parts of this workflow can run as threads. A thread is where the workflow session splits into multiple independent concurrent runs of parts of that workflow.
Run Concurrent Threads was previously named the Loop Through List component.
Example use caseโ
Let's take a look at the workflow below. At a certain time every week, this workflow will be triggered.
It will then query a database which will return a list of emails.
We want to create and assign an individual task for each email in that list that is returned. When each of those tasks is completed, we want a Slack message to be sent. To do so, we pass the list of emails from the database query into a Run Concurrent Threads component.
By passing the list of values returned by the database query into the Run Concurrent Threads, any actions after the Run Concurrent Threads will be run for each individual object in the list. So, if the database query returns us a list with 4 emails inside of it, this means the workflow will run the assign task and slack components 4 times - once for each value in that list.
If the next time this workflow was run and 10 emails were returned from the database and passed into the Run Concurrent Threads, then the subsequent Assign Task and Slack components will be run 10 times.
Setting up the Run Concurrent Threadsโ
To set up the Run Concurrent Threads, click the field and select a list type placeholder
Output from the Run Concurrent Threadsโ
The placeholder value exported from the Run Concurrent Threads will represent each value in the list used to start the thread. For example, if the input list is [A, B, C], then the output placeholder will be A for thread 1, B for thread 2, C for thread 3.
So using the example above, to assign tasks to each of the emails in the "all_emails" list, we just need to input the Run Concurrent Threads placeholder ${all_emails} as the value into the Assign Task module:
As each thread is created, the value of the ${all_emails} placeholder will be the individual emails in the input list for that thread.
Limitationsโ
You cannot merge two Run Concurrent Threads componentsโ
You cannot connect more than one Run Concurrent Threads component into another component. For example, two Start Concurrent Thread components are connected into this Assign Task:
This will cause the workflow to simply stop at the Run Concurrent Threads component - the Assign Task in this case will never run.