PHP - Threaded::isRunning() 函式



Threaded::isRunning - 狀態檢測。

語法

public boolean Threaded::isRunning( void )

Threaded::isRunning 函式可以判斷引用的物件是否正在執行。

Threaded::isRunning 函式沒有任何引數,並返回一個布林值來指示狀態。

示例

<?php
   class My extends Thread {
      public function run() {
         $this->synchronized(function($thread) {
            if(!$thread->done)
               $thread->wait();
         }, $this);
      }
   }
   $my = new My();
   $my->start();
   var_dump($my->isRunning());
   $my->synchronized(function($thread) {
      $thread->done = true;
      $thread->notify();
   }, $my);
?>
php_function_reference.htm
廣告