PHP - Threaded::notify() Function
Threaded::notify - Synchronization
Syntax
public boolean Threaded::notify ( void )
Threaded::notify() function can send a notification to referenced object.
Threaded::notify() function doesn't have any parameters and can return a boolean indication of success.
Example
<?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());
?>
php_function_reference.htm
Advertisements