从wamp-server localhost运行php多线程(使用pthread)脚本


Running php multithreaded(using pthread) script from wamp-server localhost

我正在尝试在Windows上使用php pthreads执行多线程php脚本。

我已经按照以下链接,并放置了以下文件

pthreadVC2.dll

php_pthreads.dll

按照以下链接的建议

http://emrahmehmedov.blogspot.com/2013/03/php-and-multi-thread-on-windows.html

https://github.com/krakjoe/pthreads

我还按照建议修改了php.ini文件。

问题是:

脚本在使用windows命令行使用'php'命令运行时执行得很好,但是当我尝试从浏览器从wamp-server localhost(wamp/www/)运行它时,它给出错误"未找到线程类"。下面是我的测试脚本:

    <?php
 class AsyncOperation extends Thread {
  public function __construct($arg){
   $this->arg = $arg;
  }
  public function run(){
   if($this->arg){
    for($i = 0; $i < 5; $i++) {
     echo "-> " . $this->arg . "'n";
     sleep(1);
    }
   }
  }
 }
 flush();
 $thread = new AsyncOperation("Thread 1");
 $thread2 = new AsyncOperation("Thread 2");
 $thread->start();
 $thread2->start();
 $thread->join();
 $thread2->join();
?>

你知道为什么会这样吗?有什么解决办法吗?因为我必须通过浏览器从wamp-server localhost运行脚本。请帮助。

我还启用了php_pthreads扩展从wamp GUI。

请帮忙我被困在这里2周了。

我尝试了各种方法在wamp中运行pthread,但没有运气。我放弃了,下载了xampp,它花了几分钟运行pthread