文字

Threaded::isWaiting

(PECL pthreads >= 2.0.0)

Threaded::isWaitingState Detection

说明

public boolean Threaded::isWaiting ( void )

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

参数

此函数没有参数。

返回值

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

范例

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)
上一篇: 下一篇: