开发者

How can I start two processes simultaneously?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜