PHP - Threaded::notifyOne() Function
Threaded::notifyOne - Synchronization
Syntax
public boolean Threaded::notifyOne( void )
Threaded::notifyOne() function can send a notification to referenced object. It unblocks at least one of the blocked threads.
Threaded::notifyOne() 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->notifyOne();
}, $my);
var_dump($my->join());
?>
php_function_reference.htm
Advertisements