Free preview.You're sampling one lesson — enroll free to unlock all 8 lessons and track your progress.
Enroll free
lesson

Concurrency vs. Parallelism

Concurrency vs. Parallelism

In this lesson — part of Concurrency Basics — you'll learn concurrency vs. parallelism in Kotlin and why it matters in real work.

Why it matters

Modern programs wait on networks and disks — async lets them stay responsive.

Key ideas

  • Blocking vs. non-blocking
  • Callbacks, promises, async/await
  • Concurrency vs. parallelism
  • Error handling in async code

In practice

Here's how it looks in idiomatic Kotlin:

import kotlinx.coroutines.*

fun main() = runBlocking {
    val a = async { delay(100); 2 }
    val b = async { delay(100); 3 }
    println(a.await() + b.await())   // 5, computed concurrently
}

Kotlin note: Kotlin's idiomatic concurrency is coroutines: async starts a concurrent job returning a Deferred, and await() suspends (never blocks the thread) for its result.

Try it yourself

Exercise: In Kotlin, fetch two things concurrently and combine the results.

Recap

You now understand concurrency vs. parallelism and can apply it in Kotlin. Mark this lesson complete and continue to the next one.