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