有没有人可以指导我在Windows中安装pThreads?
实际上,我想在PHP中启用线程。
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。
发布于 2013-11-19 05:42:44
http://windows.php.net/downloads/releases/php-5.5.6-Win32-VC11-x86.zip
发布于 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上找到。
https://stackoverflow.com/questions/16954113
复制相似问题