Threaded::notifyOne - 同步
用法
public boolean Threaded::notifyOne( void )
Threaded::notifyOne() 函數可以向引用的對象發送通知。它至少解除阻塞的線程之一。
Threaded::notifyOne() 函數沒有任何參數,可以返回成功的布爾值指示。
示例
<?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 Threaded::notify()用法及代碼示例
- PHP Threaded::synchronized()用法及代碼示例
- PHP Threaded::merge()用法及代碼示例
- PHP Threaded::isWaiting()用法及代碼示例
- PHP Threaded::isRunning()用法及代碼示例
- PHP Thread::isJoined()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - Threaded::notifyOne() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。