Interview PrepMidOpen-ended

What is the difference between synchronous and asynchronous execution?

Explanation & Code

Answer:

  • Synchronous — blocks the current thread until the work is done
  • Asynchronous — returns immediately; work continues on another thread or later
// Synchronous — caller waits
let data = try Data(contentsOf: url) // blocks main thread ❌

// Asynchronous — caller continues immediately
Task {
    let data = try await URLSession.shared.data(from: url).0 // non-blocking ✅
}

Rate your understanding:

Ready to practice more Interview Prep?

Test yourself with our interactive quiz mode or browse all curated questions for this topic.