在线程中实现多个对象

时间:2015-10-02 06:02:02

标签: php multithreading oop pthreads

我想在线程中使用多个对象,但是当我使用多线程时,对象的资源id是相同的。(即所有这些资源都是#2)。

mTitle

因此,我想从线程类中实现类的实例,并通过线程构造函数的参数传递对象,但这不起作用。

我想实现类似下面的代码:

class Async extends Thread
{
    public function run()
    {
        $obj = new socket($newValue); // resources id are the same  . for example #2
    }
}

但是在run方法中没有检测到该对象。

0 个答案:

没有答案