Swift's modern concurrency model — async/await, actors, and structured concurrency — was introduced in Swift 5.5 and is now the standard for concurrent iOS and macOS development. These exercises cover the key concepts and patterns for writing safe concurrent Swift code.
0 / 5 completed
1 / 5
At standup, a colleague asks what async/await enables in Swift compared to completion handlers. What is the correct answer?
async/await in Swift lets you write asynchronous code that reads like synchronous code. Marking a function async allows it to await other async functions, which suspends the current task (freeing the thread) until the awaited operation completes. This eliminates callback pyramids, makes error handling with try/catch natural, and integrates with Swift's structured concurrency system. The thread is freed during suspension — not blocked.
2 / 5
During a PR review, a teammate asks what Swift actors provide. Which answer is correct?
Swift actors protect mutable state from concurrent access. An actor's executor serialises access — only one task runs inside the actor at a time. All calls to actor methods or properties from outside the actor are implicitly async, suspending until the actor is free. This eliminates data races on actor state without explicit NSLock or DispatchQueue serialisation, and the Swift compiler enforces actor isolation at compile time.
3 / 5
In a design review, the team discusses task groups in Swift. A junior engineer asks what they enable. What is correct?
Task groups (withTaskGroup / withThrowingTaskGroup) enable structured concurrent fan-out in Swift. Inside the group closure, you call group.addTask { } to spawn child tasks that run concurrently. The group waits for all children before returning. If any child throws (in a throwing group), the group cancels remaining children and rethrows. Results are collected via for await result in group { }. This is the idiomatic way to run N concurrent tasks and aggregate results.
4 / 5
An incident report shows UI updates crashing with a main-thread violation. A senior engineer asks what @MainActor does. What is correct?
@MainActor is a global actor that ties code to the main thread. Annotating a class (e.g., your ViewModel) or specific methods with @MainActor tells the Swift compiler to schedule those executions on the main thread's executor. The compiler enforces this — calling a @MainActor method from a background task requires await, which hops to the main thread. This replaces fragile manual DispatchQueue.main.async { } calls for UI updates.
5 / 5
During a code review, a senior engineer asks what structured concurrency guarantees in Swift's task hierarchy. What is accurate?
Swift's structured concurrency creates a task hierarchy with strong guarantees. Child tasks (created via async let, TaskGroup.addTask, or within an actor) cannot outlive their parent. If the parent task is cancelled, cancellation propagates to all children. If a child throws in a throwing task group, remaining siblings are cancelled. The parent always awaits all children before returning. This prevents task leaks, makes error propagation predictable, and simplifies reasoning about concurrent lifetime.
What does the "Swift Async/Await and Actors Vocabulary" vocabulary exercise cover?
This exercise tests real IT vocabulary related to swift async/await and actors vocabulary through 5 multiple-choice questions, each built from realistic workplace sentences rather than abstract definitions.
Is this vocabulary exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is completely free — no account, sign-up, or payment required.
How many questions does this exercise have?
This exercise has 5 questions. Each one shows a real-world sentence or scenario with multiple-choice options and an explanation once you answer.
What happens after I answer a question?
You'll see immediate feedback showing whether your answer was correct, along with a short explanation of why — then a button to move to the next question, and a full results screen at the end.
Can I retry the exercise if I get questions wrong?
Yes. Once you reach the results screen, click "Try again" to reset your answers and go through the exercise from the start as many times as you like.
Do I need to create an account to take this exercise?
No account is needed. Your answers are scored in your browser during the session — nothing is saved to a server, so you can jump straight in.
Is my progress saved if I leave the page?
No — progress within an exercise resets if you navigate away or reload. Each exercise is short enough to complete in a few minutes in one sitting.
Are these vocabulary exercises connected to other topics?
Yes — browse the full vocabulary exercises hub to find related modules covering adjacent IT topics and roles.
How is this different from reading a glossary or blog article?
Exercises like this one are active recall drills — you have to choose the correct term or phrasing yourself, which builds retention faster than passively reading a definition.
Where can I find more vocabulary exercises?
Browse the full Vocabulary exercises hub for hundreds of modules covering Agile, DevOps, security, databases, architecture, and more — organised by IT role and skill.