PHP - 執行緒函式



Thread 類

每當 Thread 類的 start 方法被呼叫時,run 方法的程式碼就可以在單獨的執行緒中並行執行。

類概要

Thread extends Threaded implements Countable , Traversable , ArrayAccess {
   /* Methods */
   public void detach ( void )
   public integer getCreatorId ( void )
   public static Thread getCurrentThread ( void )
   public static integer getCurrentThreadId ( void )
   public integer getThreadId ( void )
   public static mixed globally ( void )
   public boolean isJoined ( void )
   public boolean isStarted ( void )
   public boolean join ( void )
   public void kill ( void )
   public boolean start ([ integer $options ] )
	
   /* Inherited methods */
   public array Threaded::chunk ( integer $size , boolean $preserve )
   public integer Threaded::count ( void )
   public bool Threaded::extend ( string $class )
   public Threaded Threaded::from ( Closure $run [, Closure $construct [, array $args ]] )
   public array Threaded::getTerminationInfo ( void )
   public boolean Threaded::isRunning ( void )
   public boolean Threaded::isTerminated ( void )
   public boolean Threaded::isWaiting ( void )
   public boolean Threaded::lock ( void )
   public boolean Threaded::merge ( mixed $from [, bool $overwrite ] )
   public boolean Threaded::notify ( void )
   public boolean Threaded::notifyOne ( void )
   public boolean Threaded::pop ( void )
   public void Threaded::run ( void )
   public mixed Threaded::shift ( void )
   public mixed Threaded::synchronized ( Closure $block [, mixed $... ] )
   public boolean Threaded::unlock ( void )
   public boolean Threaded::wait ([ integer $timeout ] )
}
序號 函式及描述
1

Thread::detach()

函式可以將引用的 Thread 從呼叫上下文中分離,危險!

2

Thread::getCreatorId()

函式可以返回建立引用的 Thread 的 Thread 的標識。

3

Thread::getCurrentThread()

函式可以返回對當前正在執行的 Thread 的引用。

4

Thread::getCurrentThreadId()

函式可以返回當前正在執行的 Thread 的標識。

5

Thread::getThreadId()

函式可以返回引用的 Thread 的標識。

6

Thread::globally()

函式可以在全域性作用域中執行 Callable。

7

Thread::isJoined

函式可以判斷引用的 Thread 是否已加入。

8

Thread::isStarted()

函式可以判斷引用的 Thread 是否已啟動。

9

Thread::join()

函式可以導致呼叫上下文等待引用的 Thread 完成執行。

10

Thread::kill()

函式可以強制引用的 Thread 終止。

11

Thread::start()

函式可以啟動一個新執行緒來執行已實現的 run 方法。

php_function_reference.htm
廣告