Php/docs/class.thread
(PECL pthreads >= 2.0.0)
简介
当调用 Thread 对象的 start 方法时,该对象的 run 方法中的代码将在独立线程中并行执行。
run 方法中的代码执行完毕之后,独立线程立即退出,并且等待合适的时机由创建者线程加入(join)。
Warning 依赖于引擎本身的机制检测何时加入线程可能引发非预期的行为,程序员应该尽可能的显式控制线程加入的时机。
类摘要
public detach ( ) : void
public getCreatorId ( ) : int
public static getCurrentThread ( ) : Thread
public static getCurrentThreadId ( ) : int
public getThreadId ( ) : int
public isJoined ( ) : bool
public isStarted ( ) : bool
public join ( ) : bool
public kill ( ) : void
public start
([ int $options
] ) : bool
/* 继承的方法 */
public Threaded::chunk
( int $size
, bool $preserve
) : array
public Threaded::count ( ) : int
public Threaded::extend
( string $class
) : bool
public Threaded::from
( Closure $run
[, Closure $construct
[, array $args
]] ) : Threaded
public Threaded::getTerminationInfo ( ) : array
public Threaded::isRunning ( ) : bool
public Threaded::isTerminated ( ) : bool
public Threaded::isWaiting ( ) : bool
public Threaded::lock ( ) : bool
public Threaded::merge
( mixed $from
[, bool $overwrite
] ) : bool
public Threaded::notify ( ) : bool
public Threaded::notifyOne ( ) : bool
public Threaded::pop ( ) : bool
public Threaded::run ( ) : void
public Threaded::shift ( ) : boolean
public Threaded::synchronized
( Closure $block
[, mixed $...
] ) : mixed
public Threaded::unlock ( ) : bool
public Threaded::wait
([ int $timeout
] ) : bool
}
Table of Contents
- Thread::detach — 执行
- Thread::getCreatorId — 识别
- Thread::getCurrentThread — 识别
- Thread::getCurrentThreadId — 识别
- Thread::getThreadId — 识别
- Thread::globally — 执行
- Thread::isJoined — 状态监测
- Thread::isStarted — 状态检测
- Thread::join — 同步
- Thread::kill — 执行
- Thread::start — 执行
/* 方法 */