繁体   English   中英

从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本地主机运行脚本。 请帮忙。

我还启用了php_pthreads扩展表单wamp GUI。

请帮助我被打了两个星期。

我尝试了一切以在沼泽中运行pthread并没有运气。 我放弃并下载了xampp,花了几分钟运行pthread

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM