pthread不继承definer并包含文件

时间:2016-04-23 13:03:08

标签: php pthreads

在pthread run方法中是否有任何无法继承包含文件和definer变量的可能性?我试过PTHREADS_INHERIT_NONE,但似乎  不工作我们使用了以下代码。

$domain_root='/home/user/abc';
define('DIR_FS_DOMAIN_ROOT', $domain_root);
class NEWThread extends Thread{
    public function __construct()
    {

   }
    public function run()
    {
         $this->html=DIR_FS_DOMAIN_ROOT;
    }
}
$th=new NEWThread(PTHREADS_INHERIT_NONE);
$th->start();
$th->join();
echo $th->html;

1 个答案:

答案 0 :(得分:0)

在错误的地方使用PTHREADS_INHERIT_NONE。它应该与start方法一起使用。

$domain_root='/home/user/abc';
define('DIR_FS_DOMAIN_ROOT', $domain_root);
class NEWThread extends Thread{
   public function __construct(){
   }
  public function run(){
     $this->html=DIR_FS_DOMAIN_ROOT;
  }
}
$th=new NEWThread();
$th->start(PTHREADS_INHERIT_NONE);
$th->join();
echo $th->html;