Concurrency and Paralleism in Java

Spread the love

Concurrency is defined as a concept in which multiple threads each assigned to do a task are running on a single cpu.

So the cpu does the task switching between those threads from time to time so that they appear to be running at the same time.

Paralleism is a concept in which multiple threads each assigned to do a particular tasks are running on different cpu’s. So the modern cpu’s which have multiple cores support parallelism. Parallelism requires hardware with multiple processing units, essentially. In single core CPU, you may get concurrency but NOT parallelism.

An application can be both parallel – and concurrent, which means that it processes multiple tasks concurrently in multi-core CPU at same time .

Thanks for reading!!!