在 Windows 中安装 pThreads [英] Installing pThreads in Windows
本文介绍了在 Windows 中安装 pThreads的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能指导我在 Windows 中安装 pThreads .
Can anyone guide me in installing pThreads in Windows .
实际上我想在 PHP 中启用线程.
Actually i want to enable Threads in 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() ) {
}
错误显示为不支持线程."
Error displaying is "Threads not supported."
我的 PHP 版本 5.3.4.
My PHP version 5.3.4 .
推荐答案
- 安装 ZTS(线程安全)PHP(义务)
http://windows.php.net/downloads/releases/php-5.5.6-Win32-VC11-x86.zip -
- Install ZTS (thread safe) PHP (obligation)
http://windows.php.net/downloads/releases/php-5.5.6-Win32-VC11-x86.zip Download Pthread and install http://windows.php.net/downloads/pecl/releases/pthreads/ Move php_pthreads.dll to the php\ext\ directory. Move pthreadVC2.dll to the php\ directory. enter extension=php_pthreads.dll to php.ini
尝试示例
https://github.com/krakjoe/pthreads/tree/master/examples这篇关于在 Windows 中安装 pThreads的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Install ZTS (thread safe) PHP (obligation)
查看全文