PHP - Fonction Threaded :: notifyOne ()

Threaded :: notifyOne - Synchronisation

Syntaxe

public boolean Threaded::notifyOne( void )

La fonction Threaded :: notifyOne () peut envoyer une notification à l'objet référencé. Il débloque au moins un des threads bloqués.

La fonction Threaded :: notifyOne () n'a aucun paramètre et peut renvoyer une indication booléenne de succès.

Exemple

<?php
   class My extends Thread {
      public function run() {
         /** cause this thread to wait **/
         $this->synchronized(function($thread){
            if(!$thread->done)
               $thread->wait();
         }, $this);
      }
   }
   $my = new My();
   $my->start();
   /** send notification to the waiting thread **/
   $my->synchronized(function($thread) {
      $thread->done = true;
      $thread->notifyOne();
   }, $my);
   var_dump($my->join());
?>