donh61500 2011-07-07 12:17
浏览 57

我想在php中一次执行多个方法

Hi Please help me in executing more than one method at a time in PHP.

Below is example:

<?php
function writeName()
{
sleep(3);
echo "Kai Jim Refsnes";
}
function b(){
sleep(3);
echo"b";
}
b();
writeName());
?>

Here above program take 6 sec to execute.But I want to run my both method simultaneously so that program should execute with in 3 sec(Multi threading).

  • 写回答

2条回答 默认 最新

  • dongyan9838 2011-07-07 12:19
    关注

    With common PHP its not possible, because PHP is executed sequential. You may have a look at a job-server like gearman, or you may try to use forks (pcntl_fork()). It's not multi-threading, because there is no shared memory.

    评论

报告相同问题?