Php 重用工作线程pthreads

Php 重用工作线程pthreads,php,multithreading,pthreads,Php,Multithreading,Pthreads,我遇到了一个p螺纹的情况。考虑下面的脚本: <?php class W extends \Worker { public function run() { echo "worker started\n"; } } clasds S extends \Stackable { public function run() { echo "stackable executed\n"; } } class x{ protecte

我遇到了一个p螺纹的情况。考虑下面的脚本:

<?php
class W extends \Worker {
    public function run()
    {
    echo "worker started\n";
    }
}
clasds S extends \Stackable {
    public function run()
    {
    echo "stackable executed\n";
    }
}
class x{
    protected $workers;
    protected $i;
    public function __construct()
    {
    $this->workers = array();
    $this->i = 0;
    }

    public function go()
    {
    $thread = $this->spawn();
    $j = new S;
    $thread->stack($j);
    //$thread->shutdown();
    }

    public function spawn()
    {
    $this->i !== 0 ? $n=$this->i++ : $n=$this->i;
    $thread = new W;
    $this->workers[$n] = $thread;
    $thread->start();
    return $thread; 
    }
}
$exe = new x;
$exe->go();

$thread=neww$此->工作者[$n]=$thread;还有。。。试试看,看看github上README.md中的文档;)很抱歉,这是一个输入错误。它仍然不起作用。我在pooling.php示例中观察到了同样的情况。必须在堆叠后立即调用shutdown,或者不将工作进程保存在数组中。否则会导致崩溃。还尝试了引用和splObjectStorage。结果相同。请发布实际代码,以解决问题。