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

(require '[clojure.core.async :as a :refer [chan >! <! >!! <!! go]])

(def ch (chan))
(go (>! ch (* 6 7)))      ; parks on a lightweight go-thread
(<!! ch)                  ; => 42, blocking take on main thread

;; go blocks multiplex over a small thread pool
(let [c (a/timeout 100)]
  (<!! c))                ; => nil after ~100ms

Clojure note: core.async go blocks use parking (<!/>!) on a shared thread pool rather than blocking OS threads, so never put truly blocking I/O inside a go — use the <!!/>!! blocking variants on real threads for that.

Try it yourself

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

Recap

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