Next Page > Hide TOC

NSLocking Protocol Reference

Adopted by
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.0 and later.
Companion guide
Declared in
NSLock.h

Overview

The NSLocking protocol declares the elementary methods adopted by classes that define lock objects. A lock object is used to coordinate the actions of multiple threads of execution within a single application. By using a lock object, an application can protect critical sections of code from being executed simultaneously by separate threads, thus protecting shared data and other shared resources from corruption.

Tasks

Working with Locks

Instance Methods

lock

Attempts to acquire a lock, blocking a thread’s execution until the lock can be acquired.

- (void)lock

Discussion

An application protects a critical section of code by requiring a thread to acquire a lock before executing the code. Once the critical section is past, the thread relinquishes the lock by invoking unlock.

Availability
Related Sample Code
Declared In
NSLock.h

unlock

Relinquishes a previously acquired lock.

- (void)unlock

Availability
Related Sample Code
Declared In
NSLock.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-01-22)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.