← All topics/Concurrency

Concurrency interview questions

Scenario-style prompts with sample answer outlines. Focus is on how you would design and reason in real codebases.

  1. 01Race conditions in structured concurrencyYou have multiple async tasks mutating shared state. How would you design the system to prevent race conditions?
  2. 02Keeping expensive work off the main threadYou notice UI jank when performing async work. How do you guarantee expensive work never blocks the main thread in a Swift async/await system?
  3. 03Actor design in a networking and cache stackYou're building a networking layer with caching. Where would you introduce actors, and how would you structure them to avoid contention or bottlenecks?
  4. 04Cancellation and stale async resultsYou have a screen that fires multiple async requests as the user types (such as search). How do you ensure stale requests don't overwrite newer results?
  5. 05Bridging legacy GCD to async/awaitYou're working in a large codebase that heavily uses GCD. How would you incrementally migrate it to async/await without breaking behavior?
  6. 06Task lifecycles in UIKit and SwiftUIHow do you tie the lifecycle of async tasks to a view (such as a SwiftUI view or a UIViewController) so you don't leak work or update deallocated UI?
  7. 07Debugging concurrency bugsA feature has intermittent crashes or wrong UI state under load. How do you debug suspected concurrency issues before and after they reach production?
  8. 08Parallelism with async let and task groupsYou need to load several independent resources for a screen. When do you reach for async let vs TaskGroup, and how do errors and cancellation behave?
  9. 09Task.detached: when it's justifiedWhen is Task.detached the right tool, and what guarantees do you lose compared to structured Task { }?