---
title: NSRecursiveLock
framework: foundation
role: symbol
role_heading: Class
path: foundation/nsrecursivelock
---

# NSRecursiveLock

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

## Declaration

```swift
class NSRecursiveLock
```

## Overview

Overview 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:)](foundation/nsrecursivelock/lock(before:).md)
- [try()](foundation/nsrecursivelock/try().md)

### Naming the Lock

- [name](foundation/nsrecursivelock/name.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSLocking](foundation/nslocking.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Threads and Locking

- [Thread](foundation/thread.md)
- [NSLocking](foundation/nslocking.md)
- [NSLock](foundation/nslock.md)
- [NSDistributedLock](foundation/nsdistributedlock.md)
- [NSConditionLock](foundation/nsconditionlock.md)
- [NSCondition](foundation/nscondition.md)
