Difference between concurrency and parallelism

Someone said that:

Concurrency is like a person juggling with only 1 hand. Regardless of how it seems the person is only holding at most one ball at a time. Parallelism is when the juggler uses both hands.

I understand the main assumptions.

But can someone make references?

I mean:

balls - threads?

hand - process/core?

person - processor/core?

I know this is a strange question but I believe that it could solve a basic view on this subject.

EDIT

Based on your answers I must say I'm a bit confused.

I thought that the person is a process.

This process may have many threads.

No matter whether a computer is single or multi-cores.

So one hand would be one core.

So balls are threads. And this core can handle only one thread at the time.

If there is a single-core processor and more then one thread, concurrency could be present.

Threads are switched between each other. But only one thread works at a time.

If there are a multi-core processor and many threads, each thread can be done by each core separately exactly at the same time, so parallelism is present.

What do you think?

Upvotes: 0

Views: 490

Answers (2)

Scy
Scy

Reputation: 245

Concurrency is a design where a program can continue to function without an expectation of an evaluation of a task until a certain later point,
Parallelism is one of the implementations of this design, another common one being context switching,
It's a design consideration where you allow for safe assumption that the result of the task will be non-blocking.

In this metaphor the hand is the thread executing the program, the ball is the task being executed, and the person would be the running process.
The example of a person juggling with one hand is that of context switching, you can change between separate tasks within a process and this will allow him to handle several tasks at the same time, but ultimately he never holds more than one ball at a time
Using a second hand is an implementation where he uses a second thread (hand) to simultaneously handle two tasks.

Here's a pretty straight-forward post explaining this concept https://www.quora.com/What-is-the-difference-between-concurrency-and-parallelism

Upvotes: 0

Przemyslaw Iwanczak
Przemyslaw Iwanczak

Reputation: 71

My understanding is you're asking for technicals. I found this one to be a good explanation:

What is the difference between concurrent programming and parallel programming?

Here's a visual example. Threads on a non-threaded machine:

        --  --  --
     /              \
>---- --  --  --  -- ---->>
Threads on a threaded machine:

     ------
    /      \
>-------------->>

If you like gedamial's answer - show him some love!

Upvotes: 1

Related Questions