在 Windows 中安装 pThreads [英] Installing pThreads in Windows

查看:59
本文介绍了在 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 .

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆