Thread::isJoined

(PECL pthreads >= 2.0.0)

Thread::isJoined狀態(tài)監(jiān)測

說明

publicThread::isJoined(): bool

線程是否已經(jīng)被加入(join)

參數(shù)

此函數(shù)沒有參數(shù)。

返回值

成功時返回 true, 或者在失敗時返回 false。

范例

示例 #1 檢測線程狀態(tài)

<?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->isJoined());
$my->synchronized(function($thread){
    
$thread->done true;
    
$thread->notify();
}, 
$my);
?>

以上例程會輸出:

bool(false)