PHP - Threaded::isWaiting() 函式



Threaded::isWaiting - 狀態檢測。

語法

public boolean Threaded::isWaiting( void )

Threaded::isWaiting 函式可以判斷引用的物件是否正在等待通知。

Threaded::isWaiting 函式沒有任何引數,可以返回一個表示狀態的布林值。

示例

<?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);
?>
php_function_reference.htm
廣告