Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the differences between multithreading vs concurrent vs parallel vs asynchronous programming?

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 !

like image 568
two.11 Avatar asked May 03 '17 15:05

two.11


People also ask

What are the differences between concurrent multithreaded and asynchronous programming?

Concurrency is having two tasks run in parallel on separate threads. However, asynchronous methods run in parallel but on the same 1 thread.

What is the difference between multithreading and parallel processing?

Parallel programming is a broad concept. It can describe many types of processes running on the same machine or on different machines. Multithreading specifically refers to the concurrent execution of more than one sequential set (thread) of instructions.

What is the difference between asynchronous and parallel programming?

Asynchronous programming involves some calculations time-intensive tasks, which on the one hand are engaging a thread in the background but do not affect the normal flow of the program. Parallel programming incorporates several threads to perform a task faster and so does concurrent programming.

Is multithreading concurrent or parallel?

In a multithreaded process on a single processor, the processor can switch execution resources between threads, resulting in concurrent execution.


1 Answers

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.

https://magical-parallel-computing.blogspot.com/2017/04/parallel-computing-jargon.html

I hope it helps you at a conceptual level.

like image 133
varun Avatar answered Oct 02 '22 00:10

varun