---
schema_version: "1"
id: 2ae5b178b3e6589cccfc8d21f0fabf5d95046348693addc944865484c3e784aa
title: Locking Records
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/langCon_apex_locking_records.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_records.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: c01ca3dc1aba53bef2ef9db4a3bb772471c69bba4930a721c778f6e439d9db9e
description: When an sObject record is locked, no other client or user is allowed to make updates either through code or the Salesforce user interface. The client locking the records can perform logic on the records and make updates with the guarantee that the locked records won’t be changed by another client during the lock period.
---
# Locking Records

When an sObject record is locked, no other client or user is allowed to make updates either through code or the Salesforce user interface. The client locking the records can perform logic on the records and make updates with the guarantee that the locked records won’t be changed by another client during the lock period.

- **[Locking Statements](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_statements.htm)**  
    In Apex, you can use FOR UPDATE to lock sObject records while they’re being updated in order to prevent race conditions and other thread safety problems.
- **[Locking in a SOQL For Loop](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_soql_for_loop.htm)**
- **[Avoiding Deadlocks](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_deadlocks.htm)**