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 Ruby 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 Ruby:

# Idiomatic Ruby concurrency = threads (no async/await keyword)
results = ["a", "b", "c"].map do |id|
  Thread.new { "done #{id}" }   # runs concurrently
end.map(&:join).map(&:value)
puts results.inspect             # => ["done a", "done b", "done c"]

Ruby note: Core Ruby has no async/await; the idiomatic concurrency primitive is Thread, and you collect a thread's result with join.value (the Async gem/fibers offer awaitable-style code if needed).

Try it yourself

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

Recap

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