In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
What's the difference between concurrency and parallelism? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Difference: parallelism means that multiple instructions are executed on multiple processors at the same time; both are executed together, both microscopically and macroscopically. Concurrency means that only one instruction can be executed at the same time, but multiple process instructions are rotated quickly, which makes multiple processes execute at the same time macroscopically, but not at the same time microscopically.
Concurrency and parallellism are:
Explanation 1: parallelism means that two or more events occur at the same time, while concurrency means that two or more events occur at the same time interval.
Explanation 2: parallelism is multiple events on different entities, and concurrency is multiple events on the same entity.
Explanation 3: parallelism is to process multiple tasks on multiple processors at the same time. For example, in a hadoop distributed cluster, concurrency is to process multiple tasks "simultaneously" on a single processor.
Therefore, the goal of concurrent programming is to make full use of each core of the processor to achieve the highest processing performance.
Parallel: multiple instructions are executed on multiple processors at the same time. Therefore, no matter from the micro or macro point of view, the two are implemented together.
Concurrency: it means that only one instruction can be executed at a time, but multiple process instructions are rotated quickly, which makes it have the effect of simultaneous execution of multiple processes macroscopically, but not at the same time microscopically, but only divides the time into several periods to make multiple processes execute quickly and alternately.
Parallelism exists in multiprocessor systems, while concurrency can exist in both uniprocessor and multiprocessor systems. Concurrency exists in uniprocessor systems because concurrency is the illusion of parallelism. Parallelism requires programs to perform multiple operations at the same time, while concurrency only requires programs to pretend to perform multiple operations at the same time (performing one operation per hour, and multiple operations switching quickly).
When there are multiple threads in operation, if the system has only one CPU, it is impossible for it to run more than one thread at the same time. It can only divide the CPU running time into several time periods, and then allocate the time period to each thread for execution. When the thread code of one time period is running, other threads are in a suspended state. This approach is called Concurrent.
When the system has more than one CPU, the operation of the thread may not be concurrent. When one CPU executes one thread, another CPU can execute another thread, and the two threads do not preempt CPU resources and can do so at the same time, which is called Parallel.
After reading the above, have you mastered the difference between concurrency and parallelism? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.