Lock: concept and application in variables
The Lock concept refers to a synchronization mechanism designed to prevent the simultaneous alteration of a variable's value during concurrent executions.
In Skyone Studio, this functionality is essential to ensure data integrity, ensuring that write access to a specific variable occurs in an orderly fashion, regardless of how many flow instances are being processed simultaneously.

How it works in practice
In practice, the Lock acts as a sequential access control. When activated, the system follows a suspension logic to avoid conflicts:
Write Lock: If an execution is changing the variable's value, any other execution attempting to read or overwrite that same variable will be temporarily suspended.
Execution Queue: The suspended instance waits until the first execution completes its operation.
Context Consistency: Only after the first execution is released can the next one access and modify the value, ensuring it works with the already updated data.
Why use this feature?
The main purpose of the Lock is to prevent data loss. In high-demand flows, without this control, an execution could overwrite a variable's value before the previous update was finalized, leading to incorrect calculations and process inconsistencies.
Comparative Example: The Impact of Lock
Imagine a variable called v_counter starts with the value 10. Two flow instances attempt to add +1 at the same time.
Scenario A: Without using Lock (risk of inconsistency)
In this scenario, the executions do not "see" each other, resulting in an error in the final calculation.
Step
Execution A (Instance 1)
Execution A (Instance 2)
Variable Value
1
Reads value: 10
Reads value: 10
10
2
Calculates: 10+1=11
Calculates: 10+1=11
10
3
Writes value: 11
(Waiting for CPU)
11
4
(Finished)
Writes value: 11
11 (Should be 12)
Scenario B: With Lock active (integrity guarantee)
With the feature enabled, the system organizes access and the final result is accurate.
Step
Execution A (Instance 1)
Execution A (Instance 2)
Variable Value
1
Locks and reads: 10
Tries to read and is Suspended
10
2
Adds 10+1=11
Waiting
10
3
Writes 11 and releases Lock
Waiting
11
4
(Finished)
Resumes, reads new value: 11
11
5
Adds 11+1=12 and writes
12 (Success)
Read also: Variables.
Last updated
Was this helpful?
