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 F# 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 F#:
open System.Net.Http
// 'async { }' builds a cold computation; nothing runs until started
let fetchLength (url: string) = async {
use client = new HttpClient()
let! html = client.GetStringAsync url |> Async.AwaitTask // let! = await
return html.Length
}
// Run several in parallel, collect results
[ "https://example.com"; "https://www.fsharp.org" ]
|> List.map fetchLength
|> Async.Parallel
|> Async.RunSynchronously
|> printfn "%A"
F# note: F#'s async blocks are cold and composable — they don't start until Async.Start/RunSynchronously, unlike C#'s hot Tasks — and let! is the await that propagates cancellation automatically.
Try it yourself
Exercise: In F#, fetch two things concurrently and combine the results.
Recap
You now understand concurrency vs. parallelism and can apply it in F#. Mark this lesson complete and continue to the next one.
