Are there differences between the terms Thread, Multithread, Async, and Await?

5

I asked this question here in Stack Ooverflow:

What is the solution for asynchronous processes in PHP?

I did this because I wanted to, in the middle of a process execution, want to have a certain call of a function running on the other plane, without the need for script to wait for the end of the execution to be finalized.

Talking to a friend about the subject of "PHP has no asynchronism," I was worried that I was confusing the use of threads with asynchrony.

I have several questions on the subject:

  • There is a relationship between threads and these asynchronous calls / processing (which usually uses the keywords await or async ), which exist in languages like C #, Python and NodeJS ? If they are different, what are they?

  • What would a multithread be? Is it also related to asynchronous processing?

  • I understand it right or, in these languages, calling await or async causes the program to finish execution, while the function keeps running in the background, or in fact, asynchronism means that function will just not be executed in the code writing order (same thing happens in a definition of #

I'm asking this because for me, programming in PHP, it seemed to be all the same: p

    
asked by anonymous 29.05.2017 / 13:35

1 answer

5

Thread is the mechanism that defines an application runtime.

Multithread is the ability to run multiple threads of a process that can run parallel or appear to be running parallel.

Threads are usually only needed when there is a lot of processing.

Asynchronicity does not need threads , although they can be used under certain circumstances to achieve the goal. Directly one thing has nothing to do with another.

To have something asynchronous you need to establish some form of task, either by a ready mechanism or not.

In C # you can understand the difference between a task and a thread a>.

You have a question that answers good parts of these things .

Asynchronicity allows the program to continue performing other things while it waits for some response from another party. Usually needs this when doing IO that has a certain latency.

Unless a specific implementation defines it, nothing guarantees or needs to use thread to perform asynchronicity.

Contrary to what many people think, asynchronicity does not guarantee that something runs in parallel, much less give it more performance. On the contrary, performance is worse every time. But there may be an advantage in its use because the application is not in the standby state. If everything is done right.

    
29.05.2017 / 14:00