Friday, February 9, 2018

Multithreading & Concurrency

Multithreading & Concurrency

Multithreading is a method used in computer architecture where the Central Processing Unit carries out multiple tasks in a multicore processor. Threads are the single smallest unit but are chained in multiple numbers helping in saving memory. Multithreading is different from multiprocessing as it saves memory. Whereas Concurrency is the process where multiple tasks are executed at the same time.

Multithreading in Brief:

The process of multithreading is used in computer architecture as well as in Java. But in both the places, multithreading has the same meaning that is execution of multiple threads at the same time.  Now threads are single smallest units but are lightweight and are lined up one after one and save memory. They are independent yet interconnected.

Concurrency in Brief:

Concurrency occurs when two tasks overlap each other at the time of execution. In easy terms, when two tasks happen to execute at the same time then the process in called concurrency. It is slightly different from parallelism. When two tasks start at the same time then it results in parallel concurrency. Concurrency occurs in two different ways. One is when two tasks are running and the execution is done at the same time. Second is when one task is being executed and the other is lined up for execution, both lead to concurrency.Generally, concurrency is a complex topic that requires precise understanding and execution.

Advantages of Multithreading:

There are various advantages of Multithreading. Some of them are:
  • When multiple threads run together, they make use of the unused cache and threads. This not only utilizes the resources but also boosts the speed of execution.
  • Executing multiple threads at the same time utilizes the idle threads and cache. This helps in synchronization of it values.
  • Multithreading basically saves time due to execution of multiple tasks at the same time. It also helps in best utilization of resources that makes it more efficient.

Advantages of Concurrency:

Concurrency deals with real time problems and not some already set problems. In a computer where complex problems are listed, solving it on real time basis is the challenge for the computer. Concurrency helps in making the computer more smart and efficient. A computer at one time displays the output and at the same time it revises the same output. Two tasks occur at the same time with perfection because of concurrency.

Conclusion:

Multithreading and Concurrency are near about same thing with different applications. Multithreading happens within the same process while concurrency happens for two different and independent processes. Both have their own advantages and disadvantages.

No comments:

Post a Comment