(PECL pthreads >= 2.0.0)
简介
当调用 Thread 对象的 start 方法时,该对象的 run 方法中的代码将在独立线程中并行执行。
run 方法中的代码执行完毕之后,独立线程立即退出,并且等待合适的时机由创建者线程加入(join)。
Warning
依赖于引擎本身的机制检测何时加入线程可能引发非预期的行为,程序员应该尽可能的显式控制线程加入的时机。
类摘要
Thread
extends
[Threaded](php7/class.threaded)
implements
[Countable](php7/class.countable)
,
Traversable
,
ArrayAccess
{
/* 方法 */
public [detach](php7/thread.detach)
( void
) : void
public [getCreatorId](php7/thread.getcreatorid)
( void
) : int
public static [getCurrentThread](php7/thread.getcurrentthread)
( void
) : [Thread](php7/class.thread)
public static [getCurrentThreadId](php7/thread.getcurrentthreadid)
( void
) : int
public [getThreadId](php7/thread.getthreadid)
( void
) : int
public static [globally](php7/thread.globally)
( void
) : [mixed](php7/language.pseudo-types)
public [isJoined](php7/thread.isjoined)
( void
) : bool
public [isStarted](php7/thread.isstarted)
( void
) : bool
public [join](php7/thread.join)
( void
) : bool
public [kill](php7/thread.kill)
( void
) : void
public [start](php7/thread.start)
([ int $options
] ) : bool
/* 继承的方法 */
public [Threaded::chunk](php7/threaded.chunk)
( int $size
, bool $preserve
) : array
public [Threaded::count](php7/threaded.count)
( void
) : int
public [Threaded::extend](php7/threaded.extend)
( string $class
) : bool
public [Threaded::from](php7/threaded.from)
( [Closure](php7/class.closure) $run
[, [Closure](php7/class.closure) $construct
[, array $args
]] ) : [Threaded](php7/class.threaded)
public [Threaded::getTerminationInfo](php7/threaded.getterminationinfo)
( void
) : array
public [Threaded::isRunning](php7/thread.isrunning)
( void
) : bool
public [Threaded::isTerminated](php7/threaded.isterminated)
( void
) : bool
public [Threaded::isWaiting](php7/threaded.iswaiting)
( void
) : bool
public [Threaded::lock](php7/threaded.lock)
( void
) : bool
public [Threaded::merge](php7/threaded.merge)
( [mixed](php7/language.pseudo-types) $from
[, bool $overwrite
] ) : bool
public [Threaded::notify](php7/threaded.notify)
( void
) : bool
public [Threaded::notifyOne](php7/threaded.notifyone)
( void
) : bool
public [Threaded::pop](php7/threaded.pop)
( void
) : bool
public [Threaded::run](php7/threaded.run)
( void
) : void
public [Threaded::shift](php7/threaded.shift)
( void
) : boolean
public [Threaded::synchronized](php7/threaded.synchronized)
( [Closure](php7/class.closure) $block
[, [mixed](php7/language.pseudo-types) $...
] ) : [mixed](php7/language.pseudo-types)
public [Threaded::unlock](php7/threaded.unlock)
( void
) : bool
public [Threaded::wait](php7/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 — 执行