Concurrency and Parallelism

mihalis's picture

It is a very common misconception that Concurrency and Parallelism is the same thing, which is far from true! Parallelism is the simultaneous execution of multiple things whereas Concurrency is a way of structuring your components so that they can be independently executed when possible.
It is only when you build things concurrently that you can safely execute them in parallel, when and if your operating system and your hardware permits it. The Erlang programming language did this a long time ago, long before CPUs had multiple cores and computers had lots of RAM.
In a valid concurrent design, adding concurrent entities makes the whole system run faster because more things can run in parallel. So, the desired parallelism comes from a better concurrent expression and implementation of the problem. The developer is responsible for taking concurrency into account during the design phase of a system and benefit from a potential parallel execution of the components of the system. So, the developer should not think about parallelism but about breaking things into independent components that solve the initial problem when combined.
Even if you cannot run your functions in parallel on a UNIX machine, a valid concurrent design will still improve the design and the maintainability of your programs. In other words, Concurrency is better than Parallelism!

Want to learn more about the Go Concurrency model?
Get my book Go Systems Programming from Packt or from Amazon.com.
Or get my other book Mastering Go from Packt or from Amazon.com.

Tags: