在线程中创建新对象,php

时间:2014-07-22 13:24:56

标签: php multithreading class object

我有一个简单的PHP脚本会产生分段错误。它使用PHP线程,并尝试创建一些简单的对象:

#!/usr/bin/php
<?php

class Dummy extends Threaded
{
    var $someVar;

    public function Dummy()
    {
        $this->$someVar = "some_value";
    }

    public function get_someVar()
    {
        return $this->someVar;
    }
}

class ThreadClass extends Thread
{
    var $arg;

    public function ThreadClass($arg)
    {
        $this->arg = $arg;
    }

    public function run()
    {
        echo "This is arg: ".$this->arg."\n";

        $dummy = new Dummy();
        echo $dummy->get_someVar();
    }
}

$t = new ThreadClass("bla");
$t->start();

当我运行这个时,我得到了seg错误:

[omer@omer Desktop]$ ./test1.php 
This is arg: bla

有什么问题?你能指导我这个吗?感谢。

0 个答案:

没有答案