thinkphp 中使用pthread 提示 Class 'Thread' not found

浏览:3329 发布日期:2016/07/31 分类:求助交流
写了例子程序, 单独运行 是没问题了, 但在 thinkphp里
例子程序    <?php  
    /* 
haring symbols 101 
    * @NOTE Thread::fetch was never included in a release and was superceeded by object handlers 
    *   pthreads allows read access to thread data from any context 
        pthreads allows write access to thread data from any context 
        carry on reading ... 
        work in progress ... 
    */  
    class TestObject {  
        public $val;  
    }  
      
    class Fetching extends Thread {  
        public function run(){  
            /* 
            * of course ... 
            */  
            $this->sym = 10245;  
            $this->arr = array(  
                "1", "2", "3"  
            );  
            echo '6'.chr(10);  
省略内容
可以输出正确的结果, pthread 环境安装没问题





在thinkphp里的 代码如下:<?php
 
namespace Home\Controller;
 
use Thread;

class Computer extends Thread {
    public $id;
    public $runing = false;
    public $params = null;
    public function __construct($id) {
        $this->id     = $id;
        $this->runing = true;
    }
    public function run() {
        while ($this->runing) {
            if (is_null($this->params)) {
                echo "线程[{$this->id}]等待任务...\n";
            } else {
                echo "线程[{$this->id}] 收到任务参数::{$this->params}.\n";
                $this->params = null;
            }
            sleep(1);
        }
    }
}
提示找不到 Class 'Thread' not found, 搞不懂为啥???
最佳答案
评论() 相关
后面还有条评论,点击查看>>