Showing posts with label Concurrent Programming. Show all posts
Showing posts with label Concurrent Programming. Show all posts

Tuesday, December 3, 2013

What is the difference between Concurrency and Parallelism?

Parallelism:
            Parallelism is when multiple tasks literally executing at the same time. This arises when two threads are executing simultaneously.

            Ex: Running Multiple tasks on a multi core processor.
 
Concurrency:
  • Concurrency is when multiple tasks can start, run and complete execution in overlapping time periods. It doesn't necessarily mean that they will be running at the same instant.
  • This occurs when at least two threads are making progress.
  • This is a more generalized form of parallelism that includes time-slicing as a form of virtual parallelism.
          Ex: Multitasking in a single core processor.

Concurrent Programming

Concurrent Programming?

It is about the elements and mechanisms a platform offers to have multiple tasks or programs to execute at once and communicate each other exchanging data or to synchronize to each other.


When you work with a computer, you can do several things at once. You can hear music while you edit a document in a word processor and read your e-mail. This can be done because your operating system allows the concurrency of tasks.

Is Java a Concurrent Platform?

Yes. Java is a concurrent platform and offers a lot of API to execute concurrent tasks in a Java Program. Java continuously increasing the functionalities offered to facilitate the development of concurrent programs with each version.

All Modern Operating systems allows concurrent tasks execution.

For ex, you can read emails while listening to music. This is called Process-level concurrency
But inside a process we can have multiple tasks which can be executed simultaneously.  So, the concurrent tasks that run inside a process are called as threads.