PHP 多线程扩展 pthreads

资源地址:http://www.php.net/manual/zh/book.pthreads.php

1. https://github.com/alecgorge/php_threading/

2. https://github.com/krakjoe/pthreads

刚才成功的编译后了第二个(一个似乎不是官方的标准扩展写法、估计有点儿麻烦,

而且第一个是2年前的东西了),迫不及待的写下这篇文章,介绍怎么安装:

#如果你的autoconfig版本高于2.59,则只能安装php5.4
#否则你只可以安装5.3.17。如果知道你的autoconf的版本——如果你已经安装了php.5.4那么,你就安装照5.4的安装;如果装了5.3就装5.3

#5.4
wget http://www.php.net/get/php-5.4.7.tar.gz/from/cn.php.net/mirror
tar zxvf php-5.4.7.tar.gz
cd php-5.4.7/ext

#5.3
wget http://www.php.net/get/php-5.3.17.tar.gz/from/cn.php.net/mirror
tar -xf php-5.3.17.tar.gz
cd php-5.3.17/ext


#下面装pthreads
wget https://github.com/krakjoe/pthreads/tarball/master -O pthreads.tar.gz
tar -xf pthreads.tar.gz
mv krakjoe-pthreads* pthreads
cd ../
./buildconf --force
./configure --enable-maintainer-zts --enable-pthreads --prefix=/usr/local/php-threads#其它参数自行配置,这里只是必须的参数
make
make install

源码包里面有例子,像这样执行:

/usr/local/php-threads/bin/php AdvancedSynchronization.php

Process: running
ScopeTest: 140703850592000 running
ScopeTest2: 140703839512320 running
ScopeTest2: 140703839512320 working ...
ScopeTest2: 140703839512320 notified: 1
Process: notifying 140703839512320: 1
ScopeTest: 140703850592000 notified: 1
Process: notifying 140703850592000: 1
通过apache执行的还没有试过,因为我不想破坏现有的php环境,而且我也不打算在非cli模式下执行。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值