Ways to achieve concurrency in iOS/macOS
The essence
Four levels of abstraction, from low to high:
Thread/ pthread — manual thread management. You decide how many to create, how to synchronize and when to finish. Expensive (a ~512 KB stack, context switches) and scales poorly; almost never used in app code.- GCD (
DispatchQueue) — task queues on top of a system thread pool. You describe a task and put it on a queue; the system picks the number of threads. Serial/concurrent queues, QoS,DispatchGroup, barrier. OperationQueue/Operation— an ObjC wrapper over GCD with task objects: dependencies between operations, cancellation,maxConcurrentOperationCount, KVO states. Handy for dependency graphs and cancellable pipelines.- Swift Concurrency (
async/await,Task,actor) — the language-level model since iOS 15. Structured concurrency, cooperative cancellation, compiler-checked data races (Swift 6). The default choice for new code in 2026.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep