略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Thread::start

2024-04-26

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 noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/thread.start.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3