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.