LearnViz CompSci
Home / Learn / Concurrency & Parallelism

πŸ”€ Concurrency & Parallelism

Doing many things at once. 51 topics, from beginner to advanced.

Concurrency and parallelism are about running multiple tasks at once. Concurrency structures a program to handle many tasks that may overlap in time, while parallelism runs them literally at the same time on several cores. This area covers threads, locks, race conditions, deadlocks and the asynchronous models used in modern servers and user interfaces.

Who this area is for

Developers writing servers or any program that must do several things at once, and engineers tuning multi-core performance.

Real-world use cases

Topics in Concurrency & Parallelism

Beginner (17)

Intermediate (17)

Advanced (17)

How to study Concurrency & Parallelism

Write a program with two threads that update one counter. Run it many times, observe the wrong results, then fix it with a lock or an atomic operation. Then read the memory-model topics to explain why the bug happened.

Frequently asked questions

What is the difference between concurrency and parallelism?
Concurrency is about structuring a program to manage many tasks that can interleave. Parallelism is about executing tasks at the same instant on multiple cores.
What is a race condition?
A race condition occurs when the outcome depends on the timing of threads reading and writing shared data. Protecting that data with locks or atomic operations prevents it.
What causes a deadlock?
A deadlock happens when threads each hold a resource that another needs and none can proceed. Acquiring locks in a consistent order is a common way to avoid it.
Does more threads always mean faster code?
No. Threads add overhead, and they compete for shared data and locks. Speed improves only when the work is independent and each thread has enough to do.
Why is concurrency bug-prone?
Bugs depend on timing, so they may appear rarely and vanish when you add logging. Shared mutable data and missing synchronization are the usual causes.

Open the interactive Concurrency & Parallelism area Take the Concurrency & Parallelism quiz

Other areas