Thread 类

(PECL pthreads >= 2.0.0)

简介

当调用 Thread 对象的 start 方法时,该对象的 run 方法中的代码将在独立线程中并行执行。

run 方法中的代码执行完毕之后,独立线程立即退出,并且等待合适的时机由创建者线程加入(join)。

警告

依赖于引擎本身的机制检测何时加入线程可能引发非预期的行为,程序员应该尽可能的显式控制线程加入的时机。

类摘要

classThreadextendsThreadedimplementsCountable, Traversable, ArrayAccess {
publicgetCreatorId(): int
publicstaticgetCurrentThread(): Thread
publicstaticgetCurrentThreadId(): int
publicgetThreadId(): int
publicisJoined(): bool
publicisStarted(): bool
publicjoin(): bool
publicstart(int$options = ?): bool
publicThreaded::chunk(int$size, bool$preserve): array
publicThreaded::merge(mixed$from, bool$overwrite = ?): bool
publicThreaded::synchronized(Closure$block, mixed...$args): mixed
publicThreaded::wait(int$timeout = ?): bool
}

目录

To Top