What is the differences between multithreading vs

2020-06-04 04:50发布

问题:

For a couple of days, I am wondering what is the difference between this four types of programming.I search information in Google but I cannot answer my question so I decide to ask you, can someone explain to me please? Thank you !

回答1:

The programming keywords you have mentioned refer to techniques invented for specific reasons to solve problems in the field of computation and processing.

A concise essence of what each technique aims to solve:

  • Concurrency: There are many tasks at hand, I need a steadfast progress in each of them instead of completing one and moving on to the next in a serial approach. Let me work on each of the processes so that at a given point in time, there is non-zero progress in two or more tasks. (not necessarily in simultaneity)

  • Parallelism: There is potential for doing more work in unit time given my device resources. Let me use some techniques to increase throughput, possibly sacrificing latency, so that my task(s) finish quicker.

  • Multi-threading: Both my device hardware and software have support for more than one thread of execution in a program; Let me split the computationally intensive calculations across those processors/cores/thread-pools!

  • Asynchrony: A set of tasks to be completed. I am performing one of them currently. Let me call my friend to help me out with another task, I hope he/she comes back to me with the results while I continue performing my task.

Note that the techniques discussed above are not necessarily mutually exclusive. Specifically, multi-threading is a type of parallelism, which in turn does result in degree of concurrency being more than 1 (non-trivial multi-threading).

Incidentally, I've maintained a blog about parallel computing. In one of the posts, I've written about the jargon used in the same field.

http://magical-parallel-computing.blogspot.in/2017/04/parallel-computing-jargon.html

I hope it helps you at a conceptual level.