What is concurrent programming?
what makes it slightly different from parallel programming?
In general, "concurrency" refers to two or more events, occurrences, or circumstances that occur or exist at the same time.
Concurrency allows programmes to be built as independent processes that collaborate in a given composition. Such a structure might be made parallel or not; nonetheless, obtaining such a structure in your software gives several benefits.
In programming terms, Concurrent programming is a technique in which two or more processes begin, operate in an interleaved fashion via context switching, and finish in an overlapping time period by managing access to shared resources, such as a single core of a CPU.
This does not necessarily imply that multiple processes are executing at the same time, even if the output may suggest otherwise.
Concurrent programming is frequently confused with parallel programming. So, what exactly is the distinction between concurrent and parallel programming?
Parallel processing is performed in parallel programming using hardware parallelism, such as running multiple tasks or processes on more than one independent CPU core at the same time.
Consider the following real-life scenarios between the two:
Concurrent: A Single espresso machine serves coffee to two lines of customers.
Parallel: Two espresso machines serving coffee to two lines of customers.