Threaded::isWaiting

(PECL pthreads < 3.0.0)

Threaded::isWaiting状态检测

Warning

pthreads v3 中已移除此方法。

说明

public Threaded::isWaiting ( void ) : bool

检测对象是否在等待其他线程唤醒

参数

此函数没有参数。

返回值

布尔值,表示是否处于等待唤醒状态

范例

Example #1 检测对象状态

<?php
class My extends Thread {
    public function 
run() {
        
$this->synchronized(function($thread){
            if (!
$this->done)
                
$thread->wait();
        }, 
$this);
    }
    
    protected 
$done;
}
$my = new My();
$my->start();
$my->synchronized(function($thread){
    
var_dump(
        
$thread->isWaiting());
    
$thread->done true;
    
$thread->notify();
}, 
$my);
?>

以上例程会输出:

bool(true)