php7 thread,Thread 类 - PHP 7 中文文档

(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 — 执行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值