DEV Community

Discussion on: Concurrency vs. Parallel vs. Async in .NET

scotthannen profile image
Scott Hannen Author • Edited

I think where this gets mixed up is that concurrency involves any tasks being executed at the same time. That's the literal meaning of concurrency.

Parallelism involves taking a specific set of tasks and executing them across multiple threads rather than sequentially.

That lines up with the sentence just before the one you quoted:

In programming, concurrency is the composition of independently executing processes, while parallelism is the simultaneous execution of (possibly related) computations.

In other words, concurrency means that multiple things are going on the same time (the literal meaning of "concurrent.") One user is submitting an order. Another submits an order a second later while the previous one is still processing. Another is updating profile information. All are happening at the same time.

Parallelism relates to breaking up a task into separate parts and executing them simultaneously. Perhaps a calculation can be separated into multiple calculations. There may be a number of nearly identical calculations.

I can see where there's room for confusion. Both concurrency and parallelism result in things happening at the same time on multiple threads. We could say that concurrency is incidental. We can process two requests at once, but if we get them one at a time then we only process them one at a time.

Parallelism is deliberate. I've got to do a bunch of stuff so I'm going to distribute the load across multiple threads.

That's why I separated async from the other two. While the terms have distinct meanings, in practice there's some overlap. But async is not about multiple threads.