pthreads Threaded::isRunning

(PECL pthreads >= 2.0.0)

Threaded::isRunning — State Detection


설명

public Threaded::isRunning(): bool

참조된 개체가 실행 중인지 확인


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

상태의 부울 표시

메모: run 메서드를 실행하는 동안 개체가 실행 중인 것으로 간주됩니다.


Examples

예제 #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)