Concurrency vs Parallelism

Difference Between Concurrency and Parallelism

If a system supports two or more actions at the same time , then we call the system a parallel system ,

If a system supports the simultaneous execution of two or more actions , then we call the system concurrent.

From the above description we can see that the two differences lie in the presence of keywords

  If we write multiple threads or processes in our system, reside in memory at the same time under the single-core processor cpu, and constantly switch the cpu to execute alternately, then we call it concurrency, and in this case, there can only be concurrency, and there is no way parallel.

  If in a multi-core processor, each thread or process gets its own CPU processor for simultaneous execution, then we call it parallelism. If each thread or process still cannot get its own processor in a multi-core processor, it needs to work with other threads Or processes compete to seize resources, then we also call it concurrency

 From this it can be seen that parallelism is only a subset of concurrency.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326795923&siteId=291194637