Concurrency and parallelism are not same
Khem Raj September 17, 2024 #metaConcurrency and parallelism are beautiful advanced programming concepts. Hardware continues to evolve and pack more and more compute units made available to software, concurrency and parallelism are essential for writing high-performance code. However, I have seen these terms used and misused, sometimes conflated to mean same.
Concurrency
is managing multiple tasks that are in progress but not
necessarily running/executing them at same time. Think of asyncio, threading
event loops.
Parallelism
refers to performing many computations simultaneously, a good
fit for big data processing, machine learning models. Think of python's
multiprocessing feature.
Understanding thread safety, deadlocks, race conditions, and synchronization mechanisms (like semaphores and mutexes) is crucial when working with concurrent or parallel systems.
Human mind can visualize two threads maybe three threads running and the complexity with each thread added becomes exponentially difficult to track.
These are complex and highly prone to errors, therefore modern programming languages have tried to provide concurrency handling as part of language think of go programming language.