Does php use pThread or blocking?

problem description

php some interfaces may take a long time to be called, and you want to solve it asynchronously, so you want to solve it in a multi-threaded way. Google looked up the sample code in readme.MD after the pThread, installation. It is still blocked without join.

the environmental background of the problems and what methods you have tried

the sample code in the official readme.MD often tries to find that it is blocked, so does this thread still make sense? How to solve it, we hope to solve it asynchronously.

related codes

/ / Please paste the code text below (do not replace the code with pictures)
this is the official sample code

class AsyncOperation extends Thread {
  public function __construct($arg){
    $this->arg = $arg;
  }

  public function run(){
    if($this->arg){
      sleep(5);
      // do something
      printf("Hello %s\n", $this->arg);
    }
  }
}


$thread = new AsyncOperation("World1");
$thread->start();
echo 1111;

what result do you expect? What is the error message actually seen?

what I expect is that the, do something ends after 1111 of the page is printed. Without join, the child thread handles it separately, and then shuts down on its own.

Apr.16,2021

have you ever heard of message queues?


later replace the code in / / do somthing into file conversion code, and it is found that there is no problem after testing. Even if the access is interrupted, the content of the child thread will continue to execute. The blocking behavior is caused by the characteristics of the page, which is equivalent to waiting for a callback. The final output of the page is equivalent to the completion of the callback.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e97963-4744c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e97963-4744c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?