Swift concurrency interview questions
async/await, tasks, actors, Sendable and the Swift 6.2 defaults, plus the GCD questions interviewers still ask.
– interview-ready · 17 questions in this topic
– of 17 tried
Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.
Questions
- Sequential await vs async letPredict · timeline
- async/await vs completion handlersPick the fix
- async let vs TaskGroupPick the fix · timeline
- Cooperative cancellationPredict · timeline
- Task {} vs Task.detachedPick the fix
- What is an actor?Pick the fix
- Actor reentrancy: check, await, then actPredict · timeline
- @MainActor view modelsSpot the bug
- Sendable and Swift 6 strict checkingPick the fix
- Swift 6.2: default MainActor and @concurrentPredict
- Mutex vs actorPick the fix
- Serial vs concurrent queuesPredict
- DispatchQueue.main.sync on the main threadPredict
- Reader-writer with a barrier vs an actorSpot the bug
- Bridging callbacks with AsyncStreamPredict
- OperationQueue vs GCDPick the fix
- Single-flight token refreshPick the fix
Practise this topic
Flashcards · 23
Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.
Quick quiz · 17 questions
One exercise per question, checked as you go. Needs JavaScript.
Mock interview · 3 sets
Timed, out loud, then tick what you covered. Needs JavaScript.
Fix this PR · 2 reviews
Review a diff like a senior: flag the lines you'd comment on. Needs JavaScript.
Quick facts
Recall the answer first, then tap Show to check.
QoS classes
userInteractive, userInitiated, default, utility, background. Higher QoS gets more CPU time and energy.
withCheckedContinuation
Resume exactly once. Resuming twice crashes; never resuming leaks the task, and checked continuations log a warning.
Task.yield()
Suspends briefly so other tasks can run. Useful inside long CPU loops.
Task-local values
@TaskLocalvalues flow to child tasks and Task {}, but not to Task.detached.DispatchGroup
Tracks a set of GCD work items;
notifyruns when all have finished. TaskGroup is the async equivalent.sending
A parameter or result marked
sendingcan cross isolation domains once, if the sender never uses it again (Swift 6).Swift 6.0+
Printable cheat sheet · Review your weak spots in this topic