zoukankan      html  css  js  c++  java
  • Windows环境下PHP安装pthreads多线程扩展

    一、判断PHP是ts还是nts版

    通过phpinfo(); 查看其中的 Thread Safety 项,这个项目就是查看是否是线程安全,如果是:enabled,一般来说应该是ts版,否则是nts版

    二、根据PHP ts ts版选择对应pthreads的版本

    windows版本的下载地址 : http://windows.php.net/downloads/pecl/releases/pthreads/0.1.0/

    本人php版本是5.4.17的所以下载php_pthreads-0.1.0-5.4-ts-vc9-x86.zip文件包:

    • 0.1.0表示为当前pthreads版本号
    • 5.4为php版本号
    • ts就是之前判断php对应的ts、nts版
    • vs9代表是Visual Studio 2008 compiler编译器编译的
    • 最后的x86代表的是32位的版本

    三、安装pthreads扩展

    将下载好的php_pthreads-0.1.0-5.4-ts-vc9-x86.zip文件包解压得到pthreadVC2.dll和php_pthreads.dll文件,把vc2文件放到php.exe同级目录,把php_pthreads.dll放到扩展目录ext下。
    1、修改php.ini文件 添加extension=php_pthreads.dll
    2、修改Apache配置文件httpd.conf 添加LoadFile “X:/PHP5/pthreadVC2.dll”
    3、重启Apache服务器

    四、测试pthreads扩展

    <?php
    class AsyncOperation extends Thread {
      public function __construct($arg){
        $this->arg = $arg;
      }
     
      public function run(){
        if($this->arg){
          printf("Hello %s
    ", $this->arg);
        }
      }
    }
    $thread = new AsyncOperation("World"); if($thread->start()) $thread->join(); ?>

    运行以上代码得到“HelloWorld”,就说明安装pthreads扩展成功!

  • 相关阅读:
    Maxwell的vbs脚本转matlab
    maxwell电机直观理解
    maxwell电机转矩扫描与使用MTPA策略绘制效率map图
    maxwell施加均匀外磁场
    maxwell的那些坑&小技巧
    maxwell主从边界
    MySql基础
    数据结构知识结构框架图
    第八章 多线程
    软件
  • 原文地址:https://www.cnblogs.com/feixiablog/p/13037274.html
Copyright © 2011-2022 走看看