PHP的pthreads扩展

来源:互联网 发布:嵌入式linux minitools 编辑:程序博客网 时间:2024/05/16 08:45

一、下载pthreads扩展

下载地址:http://windows.php.net/downloads/pecl/releases/pthreads

根据本人环境,我下载的是pthreads-2.0.8-5.3-ts-vc9-x86

2.0.8代表pthreads的版本。

5.3代表php的版本。

ts表示php要线程安全版本的。

vc9表示phpVisual C++ 2008编译器编译的。

x86则表示32位的

二.(1)解压后,将 php_pthreads.dll 复制到C:\wamp\bin\php\php5.3.13\ext中。

(2)将 pthreadVC2.dll复制到/wamp\bin\apache\Apache2.4.4\bin

(3)php.ini在加上一句extension=php_pthreads.dll

三.重启appache

四.测试是否安装成功

<?php

class AsyncOperation extends Thread {

    public function __construct($arg){

        $this->arg = $arg;

    }

    public function run(){

        if($this->arg){

            printf("Hello %s\n", $this->arg);

        }

    }

 }

 $thread = new AsyncOperation("World");

 if($thread->start())

    $thread->join();

 ?>

 

参考文档http://stackoverflow.com/questions/17417242/how-to-get-pthreads-working-in-php

0 0
原创粉丝点击