(PECL pthreads >= 3.0.0)
Threaded::notifyOne — 同步
發送通知到參考的物件。這會解除至少一個被阻塞的執行緒的阻塞狀態(而不是像 Threaded::notify() 那樣解除所有執行緒的阻塞狀態)。
此函式沒有參數。
範例 #1 通知和等待
<?php
class My extends Thread {
public function run() {
/** 讓這個執行緒等待 **/
$this->synchronized(function($thread){
if (!$thread->done)
$thread->wait();
}, $this);
}
}
$my = new My();
$my->start();
/** 發送通知給等待中的執行緒 **/
$my->synchronized(function($thread){
$thread->done = true;
$thread->notifyOne();
}, $my);
var_dump($my->join());
?>
上述範例將輸出
bool(true)