文字

Threaded::isRunning

(PECL pthreads >= 2.0.0)

Threaded::isRunningState Detection

说明

public boolean Threaded::isRunning ( void )

对象是否正在运行

参数

此函数没有参数。

返回值

表示运行状态的布尔值

Note:

如果对象的 run 方法正在执行,则视该对象为处于运行状态

范例

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