a shot of dev knowledge


What is concurrent programming?

Concurrency generally refers to events or circumstances that are happening or existing at the same time.

In programming terms, concurrent programming is a technique in which two or more processes start, run in an interleaved fashion through context switching and complete in an overlapping time period by managing access to shared resources e.g. on a single core of CPU.

This doesn’t necessarily mean that multiple processes will be running at the same instant – even if the results might make it seem like it.

svg viewer
svg viewer

Difference between Concurrent & Parallel programming

In parallel programming, parallel processing is achieved through hardware parallelism e.g. executing two processes on two separate CPU cores simultaneously.

A Real World Example

Concurrent: Two Queues & a Single Espresso machine.

svg viewer

Parallel: Two Queues & Two Espresso machines.