Concurrency and Parallelism are both concepts which are used in multithreading. Concurrency refers to the sequential completion of small pieces of multiple tasks such that over a period of time both of them are completed. This means that at any instant ony one task is being processed or executed. The execution of these tasks is achieved by breaking them down into smalled sub-tasks. The core processing the tasks quickly switches between tasks to make it appear that the tasks are being processed simultaneously however the process is entirely sequential.
In the above given example we can see that both the tasks are broken down into smaller sub-tasks. These sub-tasks are performed such that both the tasks are completed almost together. The key point to remember here is that both the tasks start almost together and end almost together however at any point of time only one of them is being executed.
Before understanding parallelism first let us understand what is parallel execution. Parallel execution means true simultaneous execution of tasks. This usually requires separate processing units or COREs as both tasks would be processed independant of each other on separate COREs.Parallelism is a process in which a task is divided into smaller sub-tasks and these sub-tasks are executed parallel. This means the task is executed much faster however requires multiple COREs or threads to run on. This means to save on time we must provide more computational power or in order to save on computational power we must compromise on the speed.
Be First to Comment