> For the complete documentation index, see [llms.txt](https://docs.skyone.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.skyone.cloud/english/skyone-studio/how-to/lock-concept-and-application-in-variables.md).

# 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.&#x20;

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.

<figure><img src="https://2493694111-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQPcfIOA6Tl2Bmk6CdV2O%2Fuploads%2FPGVesOJtsXs49WWRWb3J%2FCaptura%20de%20Tela%202026-04-30%20a%CC%80s%2011.17.01.png?alt=media&amp;token=1980cfa3-635d-4905-ab32-029c9e8fa7e7" alt=""><figcaption><p>The option to enable the use of locks appears when creating or editing a variable.</p></figcaption></figure>

### 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 (<mark style="background-color:$danger;">Should be 12</mark>) |

**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)                   | <p>Resumes, reads new value: 11</p><p></p> | 11                                                                         |
| 5        |                              | Adds $$11+1=12$$ and writes                | <p>12 (<mark style="background-color:$success;">Success</mark>)</p><p></p> |

Read also: [Variables](https://docs.skyone.cloud/english/skyone-studio/integrations/flows/flow-management/flow-canva-configuring-and-editing-the-flow/flow-settings.md#variables).


---

# 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://docs.skyone.cloud/english/skyone-studio/how-to/lock-concept-and-application-in-variables.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.
