开发者

How can I start two processes simultaneously?

开发者 https://www.devze.com 2023-02-17 08:45 出处:网络
I would like to start using thread with PHP. Could开发者_Go百科 someone give me an example about how to start two simultaneous processes?If you want to spawn multiple PHP processes that run in the bac

I would like to start using thread with PHP. Could开发者_Go百科 someone give me an example about how to start two simultaneous processes?


If you want to spawn multiple PHP processes that run in the background (or not), you should have a look at the manual entry on Program Execution. It lists all the methods that allow you to spawn a new process to handle background tasks

http://www.php.net/manual/en/ref.exec.php


You can fork processes with PCNTL extension. http://php.net/manual/tr/book.pcntl.php

$pid = pcntl_fork();
if ($pid) {
     // main
     pcntl_wait($status);
} else {
     // child
}
0

精彩评论

暂无评论...
验证码 换一张
取 消