Threaded::isRunning

(PECL pthreads >= 2.0.0)

Threaded::isRunningDétection de statut

Description

public Threaded::isRunning ( void ) : bool

Demande si l'objet référencé est en cours d'exécution.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Un booléen indiquant le statut.

Note:

Un objet est considéré comme étant en cours d'exécution lorsqu'il exécute la méthode run.

Exemples

Exemple #1 Détecte le statut de l'objet référencé

<?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);
?>

L'exemple ci-dessus va afficher :

bool(true)