---
title: lock()
framework: quartzcore
role: symbol
role_heading: Type Method
path: quartzcore/catransaction/lock()
---

# lock()

Attempts to acquire a recursive spin-lock lock, ensuring that returned layer values are valid until unlocked.

## Declaration

```swift
class func lock()
```

## Discussion

Discussion Core Animation uses a data model that promises not to corrupt the internal data structures when called from multiple threads concurrently, but not that data returned is still valid if the property was valid on another thread. By locking during a transaction you can ensure data that is read, modified, and set is correctly managed.

## See Also

### Managing Concurrency

- [unlock()](quartzcore/catransaction/unlock().md)
