Class

Thread

A thread of execution. 実行スレッド。

Declaration 宣言

class Thread : NSObject

Overview 概要

Use this class when you want to have an Objective-C method run in its own thread of execution. Threads are especially useful when you need to perform a lengthy task, but don’t want it to block the execution of the rest of the application. In particular, you can use threads to avoid blocking the main thread of the application, which handles user interface and event-related actions. Threads can also be used to divide a large job into several smaller jobs, which can lead to performance increases on multi-core computers. このクラスをあなたがObjective-Cメソッドをそれ独自の遂行スレッドにおいて動作してもらいたい場合に使ってください。スレッドはとりわけ役に立つのは、あなたがある非常に長いタスクを実行する必要がある、しかしそのアプリケーションの残りの遂行を遮断することをそれに望まない場合です。特に、あなたはこれらスレッドを、アプリケーションのユーザインターフェイスおよびイベント関連動作を取り扱うメインスレッドの遮断を防ぐために使用できます。スレッドはまた、ある大きなジョブをいくつかのより小さいジョブへと分割するために使用されることができます、それはマルチコアコンピュータでの性能の増大に通じます。

The Thread class supports semantics similar to those of Operation for monitoring the runtime condition of a thread. You can use these semantics to cancel the execution of a thread or determine if the thread is still executing or has finished its task. Canceling a thread requires support from your thread code; see the description for cancel() for more information. Threadクラスは、あるスレッドの実行時条件の監視のためのOperationのそれらに似た意味論をサポートします。あなたはそれら意味論を使用して、あるスレッドの遂行を取り消したり、そのスレッドがまだ遂行中かまたはそれのタスクを終了したかを決定できます。スレッドの取り消しは、あなたのスレッドコードからのサポートが必須です;cancel()をさらなる情報として見てください。

Subclassing Notes サブクラス作成の注意

You can subclass Thread and override the main() method to implement your thread’s main entry point. If you override main(), you do not need to invoke the inherited behavior by calling super. あなたは、Threadのサブクラスを作成してそのmain()メソッドをオーバーライドすることで、あなたのスレッドのもつメインエントリポイントを実装できます。あなたがmain()をオーバーライドするならば、あなたは継承された挙動をsuperを呼び出すことによって発動する必要はありません。

Topics 話題

Initializing an NSThread Object NSThreadオブジェクトを初期化する

Starting a Thread スレッドを開始する

Stopping a Thread あるスレッドを停止する

Determining the Thread’s Execution State スレッドのもつ遂行状態を決定する

Working with the Main Thread メインスレッドを取り扱う

Querying the Environment 環境を問い合わせる

Working with Thread Properties スレッドプロパティを扱う

Prioritizing Thread Work スレッド作業の優先順位を付ける

Notifications 通知

Initializers イニシャライザ

Type Methods 型メソッド

Relationships 関係

Inherits From 継承元

See Also 参照

Threads and Locking スレッドとロック