search
HomeCommon ProblemWhat is the difference between concurrency and parallelism?

Difference: Parallelism means that multiple instructions are executed simultaneously on multiple processors at the same time; both from a micro and macro perspective, both are executed together. Concurrency means that only one instruction can be executed at the same time, but multiple process instructions are executed in rapid rotation, which has the effect of multiple processes executing at the same time from a macro perspective, but not simultaneously from a micro perspective.

What is the difference between concurrency and parallelism?

Concurrency and parallelism are:

  • Explanation 1: Parallelism means Two or more events occur at the same time; 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 the simultaneous processing of multiple tasks on multiple processors. For example, in a Hadoop distributed cluster, concurrency means processing multiple tasks "simultaneously" on one processor.

So the goal of concurrent programming is to make full use of each core of the processor to achieve the highest processing performance.


Parallel: refers to multiple instructions being executed simultaneously on multiple processors at the same time. So whether from a micro or macro perspective, the two are executed together.

What is the difference between concurrency and parallelism?

Concurrency: refers to that only one instruction can be executed at the same time, but multiple process instructions are executed in rapid rotation, making it macroscopically The effect of multiple processes executing at the same time, but in a microscopic sense, is not executed at the same time. It just divides the time into several segments so that multiple processes can execute quickly and alternately.

What is the difference between concurrency and parallelism?

Parallelism exists in multi-processor systems, while concurrency can exist in both single-processor and multi-processor systems. Concurrency can exist in single-processor systems. Because concurrency is the illusion of parallelism, parallelism requires the program to perform multiple operations at the same time, while concurrency only requires the program to pretend to perform multiple operations at the same time (performing one operation per small time slice, and quickly switching execution of multiple operations).


When there are multiple threads operating, if the system has only one CPU, it is impossible to actually 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 in a time period is running, other threads are in a suspended state. This method is called concurrency (Concurrent).

When the system has more than one CPU, the thread operations may not be concurrent. When one CPU executes one thread, another CPU can execute another thread. The two threads do not seize each other's CPU resources and can proceed at the same time. This method is called parallel (Parallel).

What is the difference between concurrency and parallelism?

For more related knowledge, please visit: PHP Chinese website!

The above is the detailed content of What is the difference between concurrency and parallelism?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!