首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Windows中安装pThreads

在Windows中安装pThreads
EN

Stack Overflow用户
提问于 2013-06-06 13:14:03
回答 2查看 15.7K关注 0票数 4

有没有人可以指导我在Windows中安装pThreads?

实际上,我想在PHP中启用线程。

代码语言:javascript
复制
require_once( 'Thread.php' );

// test to see if threading is available
if( ! Thread::available() ) {
die( 'Threads not supported' );
}

// function to be ran on separate threads
function paralel( $_limit, $_name ) {
for ( $index = 0; $index < $_limit; $index++ ) {
    echo 'Now running thread ' . $_name . PHP_EOL;
    sleep( 1 );
}
}

// create 2 thread objects
$t1 = new Thread( 'paralel' );
$t2 = new Thread( 'paralel' );

 // start them
$t1->start( 10, 't1' );
$t2->start( 10, 't2' );

// keep the program running until the threads finish
while( $t1->isAlive() && $t2->isAlive() ) {

}

错误显示为“线程不受支持”。

我的PHP版本5.3.4。

EN

回答 2

Stack Overflow用户

发布于 2013-11-19 05:42:44

  • 安装ZTS (线程安全) PHP (义务)

http://windows.php.net/downloads/releases/php-5.5.6-Win32-VC11-x86.zip

  • Download Pthread和install http://windows.php.net/downloads/pecl/releases/pthreads/将php_pthreads.dll移到php\ext\目录。将pthreadVC2.dll移动到php\目录。输入extension=php_pthreads.dll to php.ini

  • try examples

https://github.com/krakjoe/pthreads/tree/master/examples

票数 4
EN

Stack Overflow用户

发布于 2013-06-06 14:24:12

您发布的代码与pthread不兼容。

http://windows.php.net/downloads/pecl/releases/pthreads/提供了用于pthread的Windows二进制文件

只需下载发行版,将扩展动态链接库(php_pthreads.dll)解压到扩展目录,将运行时动态链接库(pthreadVC2.dll)解压到php目录(与php.exe相同的目录),然后将extension=php_pthreads.dll添加到配置中

示例pthread代码可以在github http://github.com/krakjoe/pthreads上找到。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16954113

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档