CakeFest 2024: The Official CakePHP Conference

Thread::start

(PECL pthreads >= 2.0.0)

Thread::start执行

说明

public Thread::start(int $options = ?): bool

在独立线程中执行 run 方法

参数

options

可选参数,用来控制线程继承。默认值为 PTHREADS_INHERIT_ALL

返回值

成功时返回 true, 或者在失败时返回 false

示例

示例 #1 开始线程

<?php
class My extends Thread {
public function
run() {
/** ... **/
}
}
$my = new My();
var_dump($my->start());
?>

以上示例会输出:

bool(true)

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top