PHP - Fonction Threaded :: wait

Threaded :: wait - Synchronisation

Syntaxe

public boolean Threaded::wait([ integer $timeout ] )

La fonction Threaded :: wait () peut amener le contexte appelant à attendre la notification de l'objet référencé.

La fonction Threaded :: wait () 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->notify();
   }, $my);
   var_dump($my->join());
?>