Concurrency

suggest change

Introduction

Related topic: Grand Central Dispatch

Syntax

Parameters

Parameter Details
queue The queue the block runs on. A queue is not a thread: GCD runs queue blocks on a pool of threads. dispatch_get_main_queue() is the main queue. Create a queue with dispatch_queue_create("QUEUE_NAME", DISPATCH_QUEUE_CONCURRENT) or DISPATCH_QUEUE_SERIAL. The name shows up in the debugger. DISPATCH_QUEUE_CONCURRENT may run blocks in parallel. DISPATCH_QUEUE_SERIAL runs one block at a time.
block Code that runs on queue. In Xcode, double-click a block argument outlined in blue to insert an empty block.

Remarks

Work on a queue other than the main queue must stay thread-safe. Many UIView methods crash or do nothing off the main thread. Do not change variables or properties that the main thread also uses, unless that access is synchronized.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents