- PHP 手册
- 函数参考
- 进程控制扩展
- pthreads
- Threaded
Threaded::isWaiting
(PECL pthreads < 3.0.0)
Threaded::isWaiting — 状态检测
Warningpthreads v3 中已移除此方法。
说明
public Threaded::isWaiting ( void ) : bool检测对象是否在等待其他线程唤醒
参数
此函数没有参数。
返回值
布尔值,表示是否处于等待唤醒状态
范例
Example #1 检测对象状态
<?php
class My extends Thread {
public function run() {
$this->synchronized(function($thread){
if (!$this->done)
$thread->wait();
}, $this);
}
protected $done;
}
$my = new My();
$my->start();
$my->synchronized(function($thread){
var_dump(
$thread->isWaiting());
$thread->done = true;
$thread->notify();
}, $my);
?>
以上例程会输出:
bool(true)
User Contributed Notes
There are no user contributed notes for this page.官方地址:https://www.php.net/manual/en/threaded.iswaiting.php