Difference Between Concurrency and Parallelism

  Parallelism is possible only when the CPU has at least two cores, and whether it can be concurrent or not has nothing to do with the number of CPU cores, and a single-core CPU can also achieve concurrency.
  Concurrency is a special case of concurrency. Parallelism must be simultaneous in time, while concurrency only requires logical synchronization.
  For example: in college, students will make an evaluation of the teacher's lecture quality (although it is useless), and the teacher will also give the students a grade. In order to make the evaluation as fair as possible, the evaluation of the two should be completed at the same time, which emphasizes the logical simultaneity. Students can submit their evaluations to teachers before the final exam. As long as teachers are required to submit students’ grades before they can see the evaluations, it is logically guaranteed that teachers can submit grades at any time. If the time is at the same time, then the teacher and classmates must click the submit button in the educational administration system at the same time.
  Logically at the same time, it can be roughly understood as: although not at the same time in time, it is equivalent to at the same time in time. When multiple threads are running concurrently, each thread thinks it has its own CPU. Even a single CPU running multiple threads may lead to deadlocks, because even if the thread that gets the lock does not currently occupy the CPU time slice, the lock it owns will not be released, and the concurrency characteristics of multiple threads have nothing to do with the number of CPU cores. relation.

  Public number: Talk about the code today. Follow my official account to view serialized articles. If you have any questions that you don't understand, just leave a message on the official account.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325126403&siteId=291194637