Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP线程分段错误_Php_Multithreading_Pthreads - Fatal编程技术网

PHP线程分段错误

PHP线程分段错误,php,multithreading,pthreads,Php,Multithreading,Pthreads,我使用pthread开发了一个cli线程,但我遇到了一个问题: 我的代码如下: class workerThread extends Thread { private $time; public function __construct($i) { $this->i = $i; $this->time = time(); } public function run() { echo "Begin running...\n"; while (tr

我使用pthread开发了一个cli线程,但我遇到了一个问题:

我的代码如下:

class workerThread extends Thread {

private $time;

public function __construct($i) {
    $this->i = $i;
    $this->time = time();

}

public function run() {
    echo "Begin running...\n";
    while (true) {
        echo "[{$this->getThreadId()} : {$this->i}] ";
        if ($this->time + 10 < time()) {
            break;
        }
        usleep(1000000);
    }
}
}

class AppTest_Controller_Main extends Core_Controller {

    public function thread3Action() {
        error_reporting(E_ALL);
        echo "Start\n";
        $worker = new workerThread(1024);
        $worker->start();
    }
}
类workerThread扩展线程{
私人时间;
公共功能构造($i){
$this->i=$i;
$this->time=time();
}
公共功能运行(){
echo“开始运行…\n”;
while(true){
echo“[{$this->getThreadId()}:{$this->i}]”;
如果($this->time+10start();
}
}
在centos 6.5、PHPV5.5.33 zts和ptheads扩展上运行cli命令

php cli.php-r“AppTest/Main/thread3”

结果

分段故障

但我在MVC之外的文件上运行测试线程,然后它就可以工作了 这段代码在windows中工作


请帮帮我,谢谢大家

离开时,
thread3Action
$worker
将被销毁,但不会加入<代码>加入你的
开始
优雅地。。。否则,您将尝试销毁正在执行的线程…可能是