Problem Statement
Explain structured concurrency in Swift using async/await, tasks, and actors.
Explanation
Structured concurrency in Swift is an approach to manage asynchronous work by creating tasks in a well-scoped manner. /n/n Using `async` functions and the `await` keyword you can execute asynchronous code sequentially in appearance while allowing concurrency behind the scenes. Tasks can be created via `Task { … }` or `Task.detached { … }`, and they respect cancellation and lifetimes tied to their parent tasks. /n/n Actors are types that encapsulate mutable state, providing isolation and safe concurrency when accessed via `await`. Combining async/await, tasks and actors leads to safer code by avoiding manual thread management, race conditions and deadlocks. Structured concurrency offers better readability, predictable lifecycle and cancellation support, aligning with modern Swift interview topics.