Threaded::notify

(PECL pthreads >= 2.0.0)

Threaded::notify同步控制

说明

publicThreaded::notify(): bool

向对象发送唤醒通知

参数

此函数没有参数。

返回值

成功时返回 true, 或者在失败时返回 false

示例

示例 #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->notify();
},
$my);
var_dump($my->join());
?>

以上示例会输出:

bool(true)
To Top