0 votes
1 view
in Big Data Hadoop & Spark by (11.5k points)

What is the difference between concurrency and parallelism?

1 Answer

0 votes
by (24.7k points)
  • Concurrency is when multiple tasks start, run, and complete in overlapping time periods, in no specific order. Parallelism is when multiple tasks or several distributed parts of a unique task literally run at the same time, example: multi-core processor.

  • Concurrency is essentially applicable when we talk about a minimum of two tasks or more. When an application is able to execute more than one task, virtually, at the same time, it is called concurrent application. In concurrency, CPU time-slicing feature of the operating system gives an advantage where each task runs its subtasks and then go to the waiting state. When the first task is in the waiting state, the CPU is assigned to the second task to complete its subtasks.

Parallelism is a process where an application splits its tasks into smaller subtasks which can be processed in parallel. It does not require two tasks to exist at some defined time period. It has multi-core infrastructure of CPU using which it physically runs parts of tasks or multiple tasks at the same time, by assigning each task(or sub-task) a core.

  • In single core CPU, you may get concurrency but NOT parallelism because Parallelism requires hardware with multiple processing units

  • Concurrency is basically related to a process where an application handles multiple tasks it works on. Whereas, Parallelism is related to how an application handles each individual task. An application may process the task by splitting it into subtasks, which can be completed in parallel or an application may process the task serially from start to end.

  • Parallelism is about doing lots of things at once while Concurrency is about dealing with lots of things at once.

...