Concepts every developer should know: concurrency is NOT parallelism.
Parallelism and concurrency are two terms that often create confusion.
One is about managing multiple tasks at once, intermixing them to optimize resource usage.
The other involves executing multiple tasks simultaneously.
As Rob Pike (one of the creators of Golang) succinctly put it: โConcurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once."
What is concurrency?
In modern systems, concurrency is driven by design principles that ensure tasks or processes run efficiently, whether the hardware has one or multiple processors.
Even with a single CPU, concurrency patterns allow tasks to share processor time effectively. This creates an illusion of parallel execution.
These patterns also enable parts of a program to be executed out of sequence or in partial order, while still preserving the intended behavior of the program.
What is parallelism?
While concurrency is about dealing with many tasks at once (task management). Parallelism is about doing many tasks at once (task execution).
Parallelism requires hardware support, such as multi-core or multi-processor systems, to allow different tasks to run at the same time.
This distinction between concurrency (task management) and parallelism (task execution) significantly impacts application performance and efficiency.
Parallelism is particularly beneficial for compute-intensive applications, where tasks can be distributed across multiple processors to be executed simultaneously, leading to faster and more efficient processing.
Asynchronous programming is used to achieve concurrency in single-threaded environments.
This approach enables a program to initiate tasks without waiting for previous ones to finish, managing multiple tasks in a non-blocking manner.
A great example is Node.js, which handles concurrency in a single-threaded model using callbacks and event loops.
Meanwhile, multi-threaded environments (eg; C#) facilitate both concurrency and parallelism.
They facilitate both concurrent task execution and true parallel execution across multiple processors or cores simultaneously.
Understanding concurrency and parallelism is an important distinction for building high-performing and efficient software solutions.
~~
Thanks to our partner Kestra who keeps our content free to the community.
Are repetitive manual tasks slowing you down?
Kestraโs intuitive UI makes it effortless to automate and manage your workflows visually.
Check it out: https://t.co/qR5j8TKEaW
๐ Making the switch! ๐ Transitioning from Vue/Nuxt to React/Next. Nuxt3's community packages added complexity. Here's to a smoother developer journey with React/Next! #TechSwitch#ReactNext ๐โจ
First day of December is a Wednesday. That means a new batch of Jetpack releases, today including Wear Watchface 1.0.0! ๐๐๐
In addition, you'll find Collection 1.2.0, Annotation 1.2.0-rc01, Room 2.4.0-rc01, and Sqlite 2.2.0-rc01.
https://t.co/mXtKNXI00H
Just created a new blog using @hashnode. It's fast โก๏ธ, free ๐, and highly customisable โ๏ธ. Get yours here: https://t.co/RS60SxvqF1
๐: https://t.co/CZMnwc3UcB