pthreadsPHP的線程庫(kù)
該項(xiàng)目為 PHP 提供基于 POSIX 的多線程編程機(jī)制??僧惒綀?zhí)行任何與定義的用戶自定義方法和函數(shù)。內(nèi)建支持同步和同步方法。
要求:
PHP5.3+
ZTS Enabled ( Thread Safety )
Posix Threads Implementation
示例代碼:
<?php
class AsyncOperation extends Thread {
public function __construct($arg){
$this->arg = $arg;
}
public function run(){
if($this->arg){
printf("Hello %s\n", $this->arg);
}
}
}
$thread = new AsyncOperation("World");
if($thread->start())
$thread->join();
?>評(píng)論
圖片
表情
