Search⌘ K
AI Features

Concurrency vs Parallelism

Explore the distinctions between concurrency and parallelism in this lesson. Understand how concurrent systems juggle multiple tasks without simultaneous execution, while parallel systems run tasks simultaneously using multicore processors. Gain clarity on these fundamental concepts to strengthen your Java multithreading knowledge for senior engineering interviews.

Introduction

Concurrency and Parallelism are often confused to refer to the ability of a system to run multiple distinct programs at the same time. Though the two terms are somewhat related yet they mean very different things. To clarify the concept, we’ll borrow a juggler from a circus to use as an analogy. Consider the juggler to be a machine and the balls he juggles as processes.

Serial Execution

When programs are serially executed, they are scheduled one at a time on the CPU. Once a task gets completed, the next one gets a chance to run. Each task is run from the beginning to the end without interruption. The analogy for serial execution is a circus juggler who can only juggle one ball at a time. Definitely not very entertaining!

Concurrency

A concurrent program is one that can be decomposed into constituent parts and each part can be ...