pthreads Threaded::notify
(PECL pthreads >= 2.0.0)
Threaded::notify — Synchronization
설명
public Threaded::notify(): bool
참조된 개체에 알림 보내기
매개변수
이 함수에는 매개변수가 없습니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
Examples
예제 #1 알림 및 대기
<?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());
?>
위의 예는 다음을 출력합니다.
bool(true)