(PECL pthreads >= 2.0.0)
Threaded::isRunning — 狀態偵測
此函式沒有參數。
狀態的布林值指示
注意事項:
當物件執行 run 方法時,它被認為正在執行中
範例 #1 偵測參考物件的狀態
<?php
class My extends Thread {
public function run() {
$this->synchronized(function($thread){
if (!$thread->done)
$thread->wait();
}, $this);
}
}
$my = new My();
$my->start();
var_dump($my->isRunning());
$my->synchronized(function($thread){
$thread->done = true;
$thread->notify();
}, $my);
?>
上述範例會輸出
bool(true)