Return to the Alphabetic Index
Return to the Class Browser
Return to the Picture Browser
Copyright (c) 1994 by NeXT Computer, Inc. All Rights Reserved.

NSThread

Inherits From: NSObject

Conforms To: NSObject (NSObject)

Declared In: Foundation/NSThread.h

Class Description

An NSThread object controls a thread of execution. You use an NSThread when you want to terminate or delay a thread or you want a new thread.

A thread is an executable unit. A task is made up of one or more threads. Each thread has its own execution stack and is capable of independent I/O. All threads share the virtual memory address space and communication rights of their task. When a thread is started, it is detached from its initiating thread. The new thread runs independently. That is, the initiating thread does not know the new thread's state.

To obtain an NSThread object that represents your current thread of execution, use the currentThread method. To obtain an NSThread object that will create a new thread of execution, use detachNewThreadSelector:toTarget:withObject:. This method sends the specified Objective C message to the specified object in its own thread of execution. You use the NSThread object returned by these methods if you ever need to delay or terminate that thread of execution.

When you use detachNewThreadSelector:toTarget:withObject:, your application becomes multithreaded. At any time, you can send isMultiThreaded to find out if the application is multithreaded, that is, if a thread was ever detached from the current thread. isMultiThreaded returns YES even if the detached thread has completed execution.

Creating an NSThread

Querying a Thread

Delaying a Thread

Terminating a Thread