Concurrency vs Parallelism in Android?

from the CommonsWare Community archives

At September 15, 2018, 11:23am, hackzcorporation asked:

As I understand Concurrency and Parallelism

Concurrency- Dealing with multiple tasks at the same time.
Concurrency is when two tasks can start, run, and complete in overlapping time periods. It doesn’t necessarily mean they’ll ever both be running at the same instant. Eg. multitasking on a single-core machine

Parallelism- Actually executing multiple task at the same time.
Parallelism is when tasks literally run at the same time, eg. on a multicore processor.

As we know that every Android App runs in its own process and allocates some memory.As in a multithreaded app, multiple threads are running simultaneously.Does those multiple threads are running concurrently or parallely? I can assume that if the Android Device is Single Core then the multiple threads are running Concurrently. But what if the Android Device has multiple cores(e.g dual core, quad core etc), are they all running parallelly here ?

Because all those threads are running in a single process, they will use the process address space for execution.So the question is does on a multi-core android device all the threads runs parallel?


At September 17, 2018, 11:58am, mmurphy replied:

My apologies for responding later than I would have liked…

As I understand Concurrency and Parallelism

I have never seen those definitions prior to your post. I would define concurrency as “dealing with the problems created by parallel operations”.

Does those multiple threads are running concurrently or parallely?

That will depend entirely on your definition of “concurrently” and “parallelly”. I would say that both threads are running concurrently and in parallel, as to me “concurrently” and “in parallel” mean the same thing.

So the question is does on a multi-core android device all the threads runs parallel?

That is up to the device manufacturer, the kernel implementation, the CPU capabilities, the number of threads, and other environmental things (e.g., whether your app is in the foreground). For example:


At September 17, 2018, 1:00pm, hackzcorporation replied:

@mmurphy

I don’t agree that concurrency is same as Parallelism .
Concurrently is nothing but an illusion of Parallelism.Things don’t run parallely when they are concurrent.It just seem that they are running at the same time.The Cpu is switching between multiple tasks at a very high speed.Because of the speed it seems parallel.Like running multiple photos at a higher speed gives us illusion of animation.
See this video - Concurrency Is Not Parallelism


At September 17, 2018, 1:01pm, hackzcorporation replied:

Thanks for this explanation!