<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSRecursiveLock",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRecursiveLock"
  },
  "title" : "NSRecursiveLock"
}
-->

# NSRecursiveLock

A lock that may be acquired multiple times by the same thread without causing a deadlock.

```
class NSRecursiveLock
```

## Overview

[`NSRecursiveLock`](/documentation/Foundation/NSRecursiveLock) defines a lock that may be acquired multiple times by the same thread without causing a deadlock, a situation where a thread is permanently blocked waiting for itself to relinquish a lock. While the locking thread has one or more locks, all other threads are prevented from accessing the code protected by the lock.

## Topics

### Acquiring a Lock

[`lock(before:)`](/documentation/Foundation/NSRecursiveLock/lock(before:))

Attempts to acquire a lock before a given date.

[`try()`](/documentation/Foundation/NSRecursiveLock/try())

Attempts to acquire a lock, and immediately returns a Boolean value that indicates whether the attempt was successful.

### Naming the Lock

[`name`](/documentation/Foundation/NSRecursiveLock/name)

The name associated with the receiver.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)