php8.5
Home/ Manual/ pthreads / thread/ Thread::getCurrentThread

Thread::getCurrentThread

PHP function Edit on GitHub ✎

(PECL pthreads >= 2.0.0)

Identification

Description

Thread::getCurrentThread(): Thread

Return a reference to the currently executing Thread

Parameters Parameters

Return Values

An object representing the currently executing Thread

Examples

Return the currently executing Thread

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

The above example will output:

output
object(My)#2 (0) {
}

Source: reference/pthreads/thread/getcurrentthread.xml · from the official PHP manual (php/doc-en)